diff --git a/CHECKSUMS.txt b/CHECKSUMS.txt index 64187fab9569c02f0fadf869dd1c6a91fecb6822..909743aef9d67e0348ec11bc02832e69c047d12a 100644 --- a/CHECKSUMS.txt +++ b/CHECKSUMS.txt @@ -1,23 +1,23 @@ -Cover Charge v0.3.12.208: 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.208. +Cover Charge v0.3.12.209: 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.209. SHA-256 of each web app's start page, service worker, manifest and logo: -09555e50fdb07f4a34319d80b737039188e55abebadf4eac238c3c06a8d7c815 owner-app/index.html -49a8111390314153be7eb3836312b114c05ea33917f18717e52281f30f31ba20 owner-app/sw.js +bb435931e6d20f272d6ace7e5788bbf7eb414ba7c8fd53064a40d33ca57d2010 owner-app/index.html +9dbecdbb669356a1981450341c6a34f2fb7cb8cbd3040a0e73fa16c61d7a0857 owner-app/sw.js e305c44d11a9c25f37372f3fa4d329d4ffb04df2edee6e7b4b9ac91f3875ac67 owner-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 owner-app/brand-logo.png -710366575ad2b5bf03df15517e18e9287ff6550366f308b211acc82d901956ef staff-app/index.html -f790f0b4165b853ce67b9a7d46dc2c46025e844a8ce194c014153b70e74aa78a staff-app/sw.js +d20a9dd932c3ba58ea7993c550c8df41283a548a4cc1298bec556658c3f722ce staff-app/index.html +4561e14179d93391ca64a530992c76098016e423eb2b83448329289c013fc803 staff-app/sw.js bd1d310ebf8e2a80808e100c41fb7fe1c4369d3026478f3ad8eececaeadaf4ac staff-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 staff-app/brand-logo.png -7fdd01c6dbbc39ff5a30a91a7d262be2707b5ce375ca5db17d44e67f01d61b34 customer-app/index.html -53a5f040254f3899e7081a7d245e97988d1c4b9fd901376ab26f038e5cd5b7b0 customer-app/sw.js +ef9d5aed546ab97a0c1bc37c634e296110c6ebadf68906a0896987b62e916920 customer-app/index.html +f287c252eb4bd76b404d7e542da2bdb31cfdc2dca7c8e9e249742932052607d6 customer-app/sw.js 3bfb1fd10cc13f09ca6be65c461e1f6b5750ae51a3ece12e079750b2a066052e customer-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 customer-app/brand-logo.png -51ef54514b420f9d780a10cb0c81833586cd215b2ad89141008cc1a1dbb5f763 display-app/index.html -837f41113fac48f18366113876c4dcf7763ef4f6256ca49845f58c27eb65625a display-app/sw.js +503dd473daf9e39a534eceb88c01e4d81d10545071231950ffaf8c69fc68ed41 display-app/index.html +5197346abcfbaba0cd04fb47ef6c6fb43b07528281ba3ae5052a6863d211ee1a display-app/sw.js 35e2721b86eb1ae1605e55bee64177adcee72f4e53a24ac417d19ea2873434a1 display-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 display-app/brand-logo.png -918c8201101fd7266ca9db551ffccc8b7af7051db1d6a2efecc71fc7b2c5c379 chef-app/index.html -338f566ea45d29d911614fa8213e47be8ce23bc2320474861f59ce07c53083dc chef-app/sw.js +7d9aca600f0f7b774c21619e6dff5257671f32e44b83265bf24172d26981dfa4 chef-app/index.html +d2753f5a400b38c90bbb95afe2134fdc62f8cc8e666b2e9027a32c922c405af8 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 f48c607c747a748f3057bc95f33fc00260ab7939..bbc0ebb083aec94055a122b237b75edf9a512001 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,1631]); +__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,1633]); __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,1627,1630]); +__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,1629,1632]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1246,1247,1252,1254,1256,1263,1315,1316,1317,1318,1319,1320,1322,1323,1324,1325,1329,1332,1333,1334,1335,1338,1412,1413,1414,1581,1586,1587,1626]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1247,1248,1253,1255,1257,1264,1316,1317,1318,1319,1320,1321,1323,1324,1325,1326,1330,1333,1334,1335,1336,1339,1414,1415,1416,1583,1588,1589,1628]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1181,1184,1187,1198,1201,1206,1208,1209,1028,884,920,1211,1156,1212,1224,1229,1238,1231,1154,1240,1244,1202,858,1152,899,1245,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1182,1185,1188,1199,1202,1207,1209,1210,1028,884,920,1212,1157,1213,1225,1230,1239,1232,1155,1241,1245,1203,858,1153,899,1246,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,496 +1222,498 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1156,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1174,[812,17,385,85,777,779,905,858,847,906,907,804,889,1175,1179,1156,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1176,[1177,928,899,856,880,1178,1038]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1177,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1178,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1179,[17,85,780,777,905,858,908,804,889,1156,1180,8]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1180,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1181,[812,1182,17,385,85,409,777,876,851,863,804,1183,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1183,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1184,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1185,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1185,[17,777,858,1186,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1186,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1187,[812,1033,1182,17,1188,219,385,409,85,1190,1191,1192,777,816,876,851,1034,804,889,1198,1183,1057,1035,1193,856,1194,1199,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1188,[17,385,85,1189,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1189,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1190,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1191,[17,85,777,812,876,851,1190,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1192,[812,1190,17,385,85,777,884,876,1071,863,804,1183,1057,1193,856,1194,1191,1195,1197,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1193,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1194,[17,85,777,876,1008,1033,1064,1062,1193,804,856,1192,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1195,[1034,1196]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1196,[1034,1190]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1197,[17,85,777,812,1033,1034,1195,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1198,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1183,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1199,[1033,17,385,85,777,812,876,1196,1034,1200,1097,804,1187,1057,1051,1190,1195,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1200,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1201,[813,876,1202,1070,1182,923,924,17,975,976,219,385,278,85,777,858,1071,1203,1192,1162,1204,1059,805,1205,1140,851,863,804,1183,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1195,1197,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1202,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1203,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1204,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1205,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1206,[17,85,777,876,804,1057,1060,1204,1071,1207,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1207,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1208,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1209,[17,219,85,1057,876,1210,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1210,[]); -__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1211,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1212,[812,1213,779,1214,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1215,1218,1221,1223,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1213,[880,805,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1214,[17,1003,876,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1215,[219,1216]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1216,[1217,856]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1217,[928,903]); -__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1218,[813,1213,1033,779,812,1214,820,876,17,319,385,85,780,777,884,1003,1004,1219,804,889,1215,1220,8]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1219,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1220,[816,876,805]); -__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1221,[17,1033,362,219,85,777,876,1003,1220,1004,1222,804,889,1214,928,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1222,[1004,991]); -__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1223,[17,85,777,804,889,992,905,858,876,1033,1222,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1224,[17,1157,1158,385,85,777,910,845,911,804,889,1225,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1225,[813,17,319,378,385,278,85,1226,777,910,845,911,863,804,1019,8,1228]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1226,[901,17,1227,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1227,[880,899]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1228,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1229,[843,1028,17,219,385,85,780,858,804,777,1230,1104,1231,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1230,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1231,[1232,1233,1235,1234,1236,1018,1237]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1232,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1233,[824,805,831,834,856,1018,1234]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1234,[843,219,856,1232]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1235,[17,858,845,853,851,1233,1232]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1236,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1237,[17,1233,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1238,[17,385,85,409,858,845,804,777,1229,1104,1239,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1239,[17,85,409,858,845,1231,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1240,[17,219,385,85,864,777,804,916,1241,1242,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1241,[856,806,928,971,916,1231,1242]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1242,[824,1243,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1243,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1244,[17,856,1241]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1245,[17,385,329,85,409,804,1189,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1246,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1247,[843,1099,861,13,17,1248,917,85,841,1249,1079,1055,777,845,851,1105,863,858,899,804,1186,848,995,998,1076,1107,1250,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1248,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1249,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1250,[17,385,85,862,863,1033,1251,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1251,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1252,[900,13,17,319,85,1226,1253,777,845,851,858,867,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1253,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1254,[13,17,777,1255,858,1240,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1255,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1256,[822,13,17,1257,777,851,858,804,1258,1262,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1257,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1258,[17,85,777,851,1259,1260,1261,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1259,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1260,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1261,[928,899,1260]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1262,[831,928,971,899,880,1259]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1263,[1264,1265,805,1266,1275,1276,1277,843,13,17,219,385,85,1226,1253,777,845,851,862,858,900,804,1278,1240,856,876,1225,910,911,920,1279,1262,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1264,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1265,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1266,[17,85,777,1267,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1267,[806,1033,1268,1270,1272,17,85,812,777,804,1269,1273,1274,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1269,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1270,[1271,1269]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1271,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1272,[1269]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1273,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1274,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1275,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1157,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1175,[812,17,385,85,777,779,905,858,847,906,907,804,889,1176,1180,1157,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1177,[1178,928,899,856,880,1179,1038]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1178,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1179,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1180,[17,85,780,777,905,858,908,804,889,1157,1181,8]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1181,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1182,[812,1183,17,385,85,409,777,876,851,863,804,1184,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1184,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1185,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1186,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1186,[17,777,858,1187,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1187,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1188,[812,1033,1183,17,1189,219,385,409,85,1191,1192,1193,777,816,876,851,1034,804,889,1199,1184,1057,1035,1194,856,1195,1200,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1189,[17,385,85,1190,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1190,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1191,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1192,[17,85,777,812,876,851,1191,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1193,[812,1191,17,385,85,777,884,876,1071,863,804,1184,1057,1194,856,1195,1192,1196,1198,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1194,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1195,[17,85,777,876,1008,1033,1064,1062,1194,804,856,1193,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1196,[1034,1197]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1197,[1034,1191]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1198,[17,85,777,812,1033,1034,1196,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1199,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1184,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1200,[1033,17,385,85,777,812,876,1197,1034,1201,1097,804,1188,1057,1051,1191,1196,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1201,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1202,[813,876,1203,1070,1183,923,924,17,975,976,219,385,278,85,777,858,1071,1204,1193,1163,1205,1059,805,1206,1140,851,863,804,1184,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1196,1198,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1203,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1204,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1205,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1206,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1207,[17,85,777,876,804,1057,1060,1205,1071,1208,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1208,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1209,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1210,[17,219,85,1057,876,1211,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1211,[]); +__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1212,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1213,[812,1214,779,1215,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1216,1219,1222,1224,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1214,[880,805,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1215,[17,1003,876,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1216,[219,1217]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1217,[1218,856]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1218,[928,903]); +__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1219,[813,1214,1033,779,812,1215,820,876,17,319,385,85,780,777,884,1003,1004,1220,804,889,1216,1221,8]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1220,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1221,[816,876,805]); +__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1222,[17,1033,362,219,85,777,876,1003,1221,1004,1223,804,889,1215,928,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1223,[1004,991]); +__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1224,[17,85,777,804,889,992,905,858,876,1033,1223,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1225,[17,1158,1159,385,85,777,910,845,911,804,889,1226,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1226,[813,17,319,378,385,278,85,1227,777,910,845,911,863,804,1019,8,1229]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1227,[901,17,1228,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1228,[880,899]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1229,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1230,[843,1028,17,219,385,85,780,858,804,777,1231,1104,1232,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1231,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1232,[1233,1234,1236,1235,1237,1018,1238]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1233,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1234,[824,805,831,834,856,1018,1235]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1235,[843,219,856,1233]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1236,[17,858,845,853,851,1234,1233]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1237,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1238,[17,1234,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1239,[17,385,85,409,858,845,804,777,1230,1104,1240,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1240,[17,85,409,858,845,1232,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1241,[17,219,385,85,864,777,804,916,1242,1243,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1242,[856,806,928,971,916,1232,1243]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1243,[824,1244,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1244,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1245,[17,856,1242]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1246,[17,385,329,85,409,804,1190,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1247,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1248,[843,1099,861,13,17,1249,917,85,841,1250,1079,1055,777,845,851,1105,863,858,899,804,1187,848,995,998,1076,1107,1251,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1249,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1250,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1251,[17,385,85,862,863,1033,1252,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1252,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1253,[900,13,17,319,85,1227,1254,777,845,851,858,867,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1254,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1255,[13,17,777,1256,858,1241,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1256,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1257,[822,13,17,1258,777,851,858,804,1259,1263,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1258,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1259,[17,85,777,851,1260,1261,1262,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1260,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1261,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1262,[928,899,1261]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1263,[831,928,971,899,880,1260]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1264,[1265,1266,805,1267,1276,1277,1278,843,13,17,219,385,85,1227,1254,777,845,851,862,858,900,804,1279,1241,856,876,1226,910,911,920,1280,1263,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1265,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1266,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1267,[17,85,777,1268,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1268,[806,1033,1269,1271,1273,17,85,812,777,804,1270,1274,1275,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1270,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1271,[1272,1270]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1272,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1273,[1270]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1274,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1275,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1276,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1277,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1278,[17,385,85,409,777,804,1189,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1279,[17,85,1280,777,858,920,1259,1262,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1280,[17,85,1281,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1281,[1282]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1282,[17,780,1283,1312,1313,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1283,[1284]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1284,[1285,1286,1309,1311]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1285,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1286,[1287,1288,1289,1290,1291,1292,1293,1294,1295,1298,1302,1299,1303]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1287,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1288,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1289,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1290,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1295,[1296]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1299,[1300,1301]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1300,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1301,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1304,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1305,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1307,[1299,1287]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1308,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1309,[1310]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1311,[1310]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1312,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1313,[17,780,1314,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1314,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1315,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1316,[822,13,17,85,1280,777,851,858,804,1279,1262,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1317,[822,13,17,85,1257,777,858,876,851,863,804,1258,1262,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1318,[822,13,17,777,858,876,863,804,1279,1262,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1319,[822,13,17,777,858,876,804,1279,1262,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1320,[13,17,777,863,1140,1321,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1321,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1322,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1323,[843,13,17,1248,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1324,[13,17,85,1253,777,845,862,858,804,1278,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1325,[13,17,1326,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1326,[17,85,777,1099,804,1327,1328,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1327,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1328,[928,971,1327]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1329,[843,13,17,85,1255,777,845,851,863,858,804,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1330,[17,354,362,219,13,777,851,804,900,1331,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1331,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1332,[843,1262,13,17,85,777,845,851,863,858,864,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]})}},1333,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1334,[822,13,17,777,858,805,1262,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1335,[13,17,777,1336,1153,1262,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1336,[812,843,17,85,777,845,851,1153,1337,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1337,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1338,[13,17,856,1339,1410,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1339,[1053,779,805,806,1340,813,1341,1094,843,1140,1342,1343,1344,1091,1122,1345,1346,1351,1352,1209,1353,856,1358,1359,1360,1115,1113,920,1361,1152,891,1104,1362,17,1072,1184,1018,1087,1363,378,363,385,278,85,409,19,777,1240,1244,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1364,1108,1365,1371,1373,1376,1381,1375,1382,1385,1386,1117,1095,1096,862,1391,1229,1392,1239,1231,995,1397,1402,1403,1054,1052,1119,1405,1406,1407,1071,1171,1408,1170,1161,853,1354,1409,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1342,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1343,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1344,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1345,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1346,[17,378,385,409,85,1280,777,1171,779,998,1347,1348,1350,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1347,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1348,[17,378,385,278,395,85,409,779,777,804,1349,1350,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1349,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1350,[993,856,1349,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1351,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1352,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1353,[1167,17,219,385,85,777,1166,804,876,920,1354,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1354,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1355,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1355,[831,928,899,1356,880,1357]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1356,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1357,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1358,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1360,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1361,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1362,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1363,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1364,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1365,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1366,1368,1367,998,876,1108,1369,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1366,[813,843,17,1367,85,842,804,777,1109,1368,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1367,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1368,[1367,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1369,[17,368,278,85,842,982,1370,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[17,219,385,85,804,777,1171,1372,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1374,804,777,1375,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1376,[805,813,17,266,319,219,385,85,409,804,857,1377,777,999,916,1351,1379,880,1380,1381,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1377,[17,219,85,1378,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1378,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1379,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1381,[17,831,928,899,1380]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1382,[843,841,998,1383,1384]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1383,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1384,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1385,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1386,[1387,843,1095,998,17,85,777,1098,858,1116,1382,1096,863,1093,1117,1118,1119,804,1343,1389,1390,1115,1360,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1387,[17,362,385,85,858,920,876,996,1388,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1388,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1391,[1171,1387,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1375,858,998,845,1089,1076,1321,804,1343,1389,1390,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1392,[812,17,219,385,85,777,858,998,1393,804,1394,1396,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1393,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1394,[831,858,998,1393,1395,1396]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1395,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1396,[219,1395]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1397,[843,17,1188,1171,385,85,995,998,862,863,804,777,1398,1401,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1398,[1399,854,843,17,264,378,385,278,85,858,995,998,1400,863,804,1026,777,1401,1355,899,1343,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1399,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1400,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1401,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1403,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1404,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1405,[843,1383]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1406,[17,385,85,777,1405,804,1363,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1407,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1408,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[17,1005,876,926,816,1006,916,1355,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[805,813,857,17,219,385,85,409,899,804,777,1351,1411,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); -__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]})}},1412,[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]})}},1413,[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,{})}},1414,[13,17,1415,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])},1415,[17,856,1416,1557,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 H.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]),Y=_r(d[45]);_r(d[46]);var 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,Q.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,Q.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,K.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,K.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,J.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)(()=>{G.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,M.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)(z.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)(z.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'!==H.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'===H.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'===H.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.jsx)(D.AssistantRequestsButton,{go:Be,testID:"assistant-requests-top"}),(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'===H.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)(F.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(Y.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(U.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(Q.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(K.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.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)(W.OnboardingHost,{go:Be}),(0,le.jsx)(V.CoachHost,{})]})}},1416,[805,813,899,1192,1227,1209,1028,1025,891,1026,880,1032,1087,17,356,378,385,278,409,85,19,777,857,858,876,804,1417,1183,1057,884,1425,920,219,1430,1470,839,856,1472,1479,1480,1481,1189,1245,1482,1456,1483,1485,1454,1160,1229,1392,1231,1244,1487,1084,1086,1553,1554,1573,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1417,[805,1418,1095,1269,1419,812,822,1117,1118,1091,1122,1420,1114,1119,1405,1406,1057,1343,996,1120,1089,841,1384,1125,1422,1240,1423,1397,1078,1055,1090,17,85,777,1363,858,845,851,863,1321,804,1183,1098,1115,998,1360,1062,1161,1424,1231,899,1185,1402,862,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1418,[]); -__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])},1419,[806,17,85,777,899,1273,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[17,385,85,1421,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1186,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1424,[17,85,864,858,848,804,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1425,[1426,17,219,24,85,856,1427,920,804,1429,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1426,[]); -__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])},1427,[17,278,85,777,857,804,1428,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(' ')},1428,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1429,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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:n=!1}){const{rid:a,r:x,now:H,role:ae,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(a),ce=(0,p.useBookings)(a),ue=(0,p.useWaitlist)(a),ge=(0,p.useEvents)(a),xe=(0,p.useRatings)(a),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,S.useRealHistory)(a,H),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,H,pe??void 0),[x,ce,de,ge,pe,H.getTime()/6e4|0]),ke=(0,M.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),Ie=de.filter(B.LIVE),ve=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=Ie.filter(e=>(0,U.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,U.bookingNeedsAction)(e,Ie)),Ae=Ie.flatMap(e=>(0,I.readinessFor)(e,x,H).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Se=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Me=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,v.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(H),He=ke?(0,L.revenueHistory)(x,H,7).filter(e=>e.date.getDay()===H.getDay()).pop():void 0,Fe=ke?{today:186e3+Ne,last:He?{date:(0,v.ymd)(He.date),pence:He.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,a,Pe,Ne),We=j.CAN.takings(ae)&&(!(0,W.isLive)()||(0,W.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,H,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(H),(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)(ae,qe,{inStaffApp:Ye,live:(0,W.isLive)()}),Ve=(0,F.homeSetupNagsHidden)(a),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,st]=(0,l.useState)(!1),ot=ie.replace(' (example)',''),lt=j.CAN.manage(ae)?(0,ne.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,ne.jsxs)(b.default,{style:{gap:12},children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(i.DayView,{rid:a,day:Ue,today:re,app:"owner"})]}):(0,ne.jsxs)(b.default,{style:{gap:12},testID:n?'owner-home':'managers-home',children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(K.WhoBar,{}),qe&&'owner'!==qe.role?(0,ne.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ne.jsx)(X.MyTasksToday,{rid:a,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ae?(0,ne.jsx)(Z.TodaysTipsCard,{rid:a,today:re}):null,'staff'!==ae?(0,ne.jsx)(Z.TipsPotCard,{rid:a,today:re}):null,j.CAN.manage(ae)?(0,ne.jsx)(b.default,{testID:"home-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.jsx)(f.Button,{testID:"home-insights-toggle",kind:tt?'secondary':'primary',label:tt?'Hide insights':'Insights',accessibilityLabel:tt?'Hide insights':'Insights: business insights, stats and suggestions. Closed until you tap.',onPress:()=>st(e=>!e),style:{minHeight:56,width:'100%'}})}):null,j.CAN.manage(ae)&&tt?(0,ne.jsxs)(b.default,{testID:"home-insights-panel",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,ne.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.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%'}})}),(0,ne.jsx)(le.SuperProInsights,{go:e}),(0,ne.jsxs)(b.default,{testID:"home-insights-feed",style:{gap:12,width:'100%'},children:[(0,ne.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,ne.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ne.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,ne.jsxs)(f.T,{weight:"semibold",center:!0,children:[t.icon," ",t.title]}),(0,ne.jsx)(f.Muted,{center:!0,children:t.body}),t.action?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'center'}}):null]})},t.id)),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights'),style:{alignSelf:'center'}})]})]}):null,(0,ne.jsx)(ye,{split:De}),(0,ne.jsx)(te.BlocksBanner,{rid:a,now:H,by:ie}),(0,ne.jsx)(y.KitchenSignoffs,{rid:a,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(o.SeasonsTodo,{go:e}):null,(0,ne.jsx)(r.LastFoodBanner,{rid:a,now:H}),(0,ne.jsx)(d.NextTableFreeCard,{rid:a,now:H}),j.CAN.manage(ae)?(0,ne.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,ne.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,ne.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ne.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ae)?(0,ne.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:a,r:x,now:H,by:ie}):null]}),ze.elements,j.CAN.manage(ae)?(0,ne.jsx)(Y.PaydaysCard,{go:e}):null,(0,ne.jsx)(E.FadeIn,{children:(0,ne.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ne.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,ne.jsx)(S.ExampleBadge,{}):je.enough?(0,ne.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ne.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ne.jsx)(E.Gauge,{pct:Le?Se.pct:0,label:Le?Se.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,ne.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ne.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,je.enough?(0,ne.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,ne.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ne.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ne.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||Ie.length?(0,ne.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Live orders",value:"",accent:Ie.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${Ie.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${Ie.filter(e=>'table'===e.type).length} table`:`${Ie.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ne.jsx)(E.CountUp,{value:Ie.length})})}):null,ve.length>0?(0,ne.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ne.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,ne.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(z.TakingsTodayCard,{t:Fe,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ne.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ne.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,ne.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,ne.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ne.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,v.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ne.jsx)(f.T,{size:14,children:t.detail}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ge.days.length||Ge.requests)?(0,ne.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,ne.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ae)?(0,ne.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ne.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ne.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ne.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,ne.jsxs)(f.Row,{gap:4,children:[(0,ne.jsx)(G.Mark,{p:"facebook"}),(0,ne.jsx)(G.Mark,{p:"instagram"}),(0,ne.jsx)(G.Mark,{p:"tiktok"}),(0,ne.jsx)(G.Mark,{p:"youtube"})]}),(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ne.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ne.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ne.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ne.jsx)(B.SectionHead,{title:e})}),(0,ne.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ne.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ne.jsxs)(f.Card,{children:[0===Oe.length?(0,ne.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,ne.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ne.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,v.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ne.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ne.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),Ke?(0,ne.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,ne.jsx)(E.FadeIn,{children:(0,ne.jsx)(he,{rid:a,today:re})}):null,'owner'!==ae||V.IS_CAR?null:(0,ne.jsx)(f.Button,{testID:"home-customer-support",label:"Customer support",accessibilityLabel:"Customer support, send a message or a picture to CoverCharge",onPress:()=>e('more','support'),style:{minHeight:56,width:'100%'}}),(0,ne.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:a,by:ot,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]),n=_r(_d[4]),a=e(n),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]),I=_r(_d[21]),v=_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]),S=_r(_d[29]),M=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),H=_r(_d[33]),F=_r(_d[34]),W=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),_=_r(_d[41]),U=_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]),ne=_r(_d[56]);const ae=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 a=3/Math.sqrt(n);o[e]=a*t*s[e],o[e+1]=a*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)&&n.push(e);for(;n.length&&o(e)-o(n[n.length-1])<36;)n.pop();return[...n,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&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/I*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:v(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],S=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?.(M(s)))},M=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,F=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,W=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)} ${F}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${W?` ${W.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,n)=>(0,ne.jsx)(m.default,{testID:n,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,ne.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ne.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ne.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ne.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ne.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,ne.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,ne.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ne.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:F}),(0,ne.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),W?(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:W}):null]}):(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ne.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ne.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ne.jsxs)(a.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ne.jsx)(n.Defs,{children:(0,ne.jsxs)(n.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ne.jsx)(n.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ne.jsx)(n.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ne.jsx)(n.Line,{x1:ae,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.Circle,{cx:v(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ne.jsx)(n.Line,{x1:v(L.day),y1:10,x2:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:M(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:v(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ne.jsx)(b.default,{testID:"mt-axis",style:{height:H.AXIS_BAND+6,minHeight:H.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ne.jsx)(f.T,{size:H.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:v(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ne.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ne.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>S(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ne.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:M(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ne.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ne.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,ne.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>S(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,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ne.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: card + cash \u2212 card tips. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ne.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ne.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,ne.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ne.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ne.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,ne.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ne.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1430,[843,1140,1431,17,780,1184,1074,1075,1423,1343,861,1078,264,385,85,777,858,876,1210,1192,845,1159,863,1055,866,804,1183,1057,1139,1144,1145,1008,839,1149,886,899,915,1441,1442,1148,1443,1161,853,1446,1187,1208,856,1206,1031,1032,1066,1098,1397,1152,1342,1464,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."})]})}},1431,[1053,1033,805,1418,812,1432,1433,1435,1436,1437,1202,1031,1032,1008,1014,17,385,85,777,841,1438,816,862,1055,861,804,1057,858,1186,926,927,876,1439,1392,998,1440,1005,1142,892,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)},1432,[812,17,85,777,1140,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)},1433,[843,17,219,85,777,858,998,1153,1262,899,1337,1434,8]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1434,[843,1284]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1435,[17,85,777,998,1347,804,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1436,[17,85,777,998,863,1400,805,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1437,[]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1438,[17,1033,85,804,777,1259,1262,8]); -__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1439,[17,85,777,998,1367,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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),S=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>C(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>C(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>f(null),onSave:t=>{y.update(e.id,t),f(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",S(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>f(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:I,onCancel:()=>f(null),onSave:t=>{y.add(e,t),f(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>f('new')}),(0,k.jsxs)(r.Sheet,{visible:!!p,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:p?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{p&&y.remove(p.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{f.useOrderLists.getState().ensure(e)},[e]);const s=(0,f.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,f.orderSettingsOf)(e);(0,f.useOrderLists)(t=>t.settings[e]);const l=f.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),f=(0,s.privateClockVenue)(e),[p,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[S,v]=(0,n.useState)(!1),[C,I]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(f)return;v(!0),I('');const t=await(0,b.getFix)();if(v(!1),'object'!=typeof t)return void I('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),I(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:f?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),f?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),f?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:S?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:S,onPress:()=>{B()}}),C?(0,k.jsx)(r.Muted,{size:13,children:C}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:p,onChangeText:j,onBlur:()=>R(p,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(p,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),f?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"The full CookSafe log is in the food safety menu: CookSafe log."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_r(_d[5])),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},S=[1,2,3,4,5,6,0],v=['on_shift','everyone','managers','head_chef','kitchen','foh'],C=e=>e.replace(' (example)',''),I={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:C(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[v.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:C(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,f]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),p=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{f(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:S.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),p?(0,k.jsx)(r.Muted,{size:13,children:p}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!p,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>f.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1440,[812,912,17,362,385,85,777,804,1005,1006,876,1010,1011,1012,913,1068,899,1029,916,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1441,[]); -__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7])},1442,[17,385,85,777,804,1148,1441,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1443,[886,779,816,813,822,862,1039,1444,17,909,319,362,219,385,85,777,858,876,863,804,1183,1057,1220,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1444,[482,1445]); -__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}});var t={}},1445,[]); -__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.ProgressBar=L,_e.useSetupDone=F,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,T.useCtx)(6e4),n=F(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=k.SETUP_STEPS.findIndex(e=>e.id===a),s=k.SETUP_STEPS[e+1]?.id??null;return(0,R.jsx)(A,{id:a,wizard:!0,onBack:()=>l(e>0?k.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=k.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,R.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{gap:12,children:[(0,R.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsxs)(m.T,{size:20,weight:"bold",colour:C.colours.gold,children:["Set up ",t.name]}),(0,R.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,R.jsx)(L,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,R.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,R.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:C.colours.border,backgroundColor:C.colours.surface,overflow:'hidden'},children:k.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,R.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:C.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,R.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?C.colours.gold:'transparent',borderWidth:1.5,borderColor:t?C.colours.gold:C.colours.border},children:(0,R.jsx)(m.T,{weight:"bold",colour:t?C.colours.onGold:C.colours.muted,children:t?'\u2713':s+1})}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"medium",children:e.title}),(0,R.jsx)(m.Muted,{children:e.sub}),o.length?(0,R.jsxs)(m.T,{size:13,colour:C.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,R.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=A,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return V}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=F(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,R.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",colour:C.colours.gold,children:"Finish setting up"}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]}),(0,R.jsx)(L,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,R.jsxs)(m.Muted,{size:13,children:["Next: ",k.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]),M=_r(_d[29]),R=_r(_d[30]);const I=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=[1,2,3,4,5,6,0],B=/^([01]\d|2[0-3]):[0-5]\d$/,D=e=>{const s=(0,M.parseMoneyInput)(e);return null!=s&&s>0?Math.round(100*s):null},O=e=>k.SETUP_STEPS.findIndex(s=>s.id===e)+1;function L({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,R.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,R.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:C.colours.gold,borderRadius:5}})}),(0,R.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function F(e){const s=(0,k.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=k.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:k.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function A({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,T.useCtx)(6e4),l=F(a),r=l.prog,d=(0,i.useLiveVenue)(),u=k.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=N[e];return(0,R.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsxs)(m.T,{size:12,weight:"semibold",colour:C.colours.gold,children:["STEP ",O(e)," OF ",k.SETUP_STEPS.length]}),s&&o?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,R.jsx)(m.T,{size:13,colour:C.colours.muted,children:"All steps"})}):null]}),(0,R.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,R.jsx)(L,{done:r.done,total:r.total})]}),(0,R.jsx)(b,{rid:a,done:(t="Saved.")=>{k.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,R.jsx)(m.Banner,{kind:"success",title:p}):null,(0,R.jsx)(G,{rid:a,id:e,title:u.title,onDone:x}),s?(0,R.jsxs)(m.Row,{gap:10,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,R.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const U=({wizard:e,onPress:s,disabled:t,label:n})=>(0,R.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const _=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function W({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,T.useHourly)(),d=(0,k.useSiteSetup)(e),u=(0,k.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,f]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,S.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,k.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),f(null)},z=!!p?.id&&(E=p.id,w.ROSTER.some(e=>e.id===E));var E;const M=p?D(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=M||z&&!p.wage);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,R.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,R.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?C.colours.gold:C.colours.border,backgroundColor:s?'#1d1a14':C.colours.surface}),children:[(0,R.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"semibold",children:e.name}),(0,R.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,k.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,R.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,k.accessOf)(e.level,e.role)})]},e.id))}),y?(0,R.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:C.colours.gold},children:(0,R.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,R.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,R.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,R.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,R.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,R.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Access level"}),(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:k.ACCESS_LEVELS.map(e=>(0,R.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,R.jsxs)(m.Muted,{size:13,children:["Uses the ",k.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Pay"}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,R.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,R.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,R.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,R.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,S.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,R.jsx)(m.Field,{money:!0,label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=M&&M<1271?(0,R.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,R.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,R.jsxs)(m.Row,{gap:8,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,R.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),k.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:k.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=M&&s.setRate(t,M);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),k.useSetup.getState().patch(e,{staffGrade:o}),k.useSetup.getState().setLook(t,p.look),f(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,R.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,R.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(_(d.grades[0]?.id??'')),f(null)}}),(0,R.jsx)(U,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const N={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,k.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,R.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,R.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,R.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,R.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':(0,y.builtInLogoCopy)(e)," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,R.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,R.jsx)(z.OrderAtTableCard,{rid:e,compact:!0}),u?(0,R.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,R.jsx)(U,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,T.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=$.filter(e=>{const s=n[e];return s&&(!B.test(s[0])||!B.test(s[1]))});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),I.map((e,s)=>{const t=$[s],l=n[t];return(0,R.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:C.colours.border,paddingTop:s?6:0},children:[(0,R.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,R.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"to"}),(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,R.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,R.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries($.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,R.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,R.jsx)(U,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,f.usePlan)(e),o=(0,f.planCounts)(n);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P.TablePlan,{startStep:"areas"}),(0,R.jsx)(U,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,R.jsx)(W,{...e,payList:!0})]})},staff:W,permissions:function({done:e,wizard:s}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E.PermissionsScreen,{}),(0,R.jsx)(U,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,k.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,R.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,R.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,R.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,R.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,R.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,R.jsx)(U,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),a=(0,k.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,v.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,R.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,R.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:C.colours.border,padding:10},children:(0,R.jsx)(m.T,{size:14,colour:C.colours.goldLight,children:i})}),(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,v.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,R.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,R.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,R.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,R.jsx)(U,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),k.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,T.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,R.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,R.jsx)(U,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},V=e=>function(){return(0,R.jsx)(A,{id:e})};function G({rid:e,id:s,title:t,onDone:n}){const o=F(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,R.jsxs)(g.default,{style:{gap:4},children:[(0,R.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),k.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,R.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,R.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1446,[888,887,813,812,1039,1447,1448,1449,1450,1452,17,385,85,857,884,777,858,876,1453,998,886,878,851,804,1057,1454,1457,1461,1462,840,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1447,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1448,[17,899]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1449,[17,831,899]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1450,[880,812,17,219,366,85,777,1451,899,804,1187,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1451,[]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1452,[17,385,777,899,804,1450,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.builtInLogoCopy=function(o){return'anchorage'===o?'The Anchorage logo in black and gold.':'Placeholder initials.'}},1453,[]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1454,[812,891,1140,899,780,1229,1231,17,264,362,219,385,85,409,864,777,858,1240,876,851,863,804,1183,1057,853,1055,1443,1160,1455,1456,1139,1145,1144,1008,839,1142,1148,1220,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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1455,[812,17,1227,1026,854,362,385,85,777,876,851,863,804,1183,1057,1220,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1456,[978,17,385,85,777,876,804,1057,1160,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1457,[812,17,1018,378,85,1108,1109,1365,1397,777,995,998,863,804,1057,999,1458,1459,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1458,[812,17,385,85,777,804,998,805,999,856,899,8]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1459,[17,85,777,998,1460,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1460,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1461,[805,1418,17,85,777,858,876,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.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 ')}},1462,[17,264,385,85,777,804,915,1463,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.'},1463,[928,899,876,856,915]); -__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 P}}),_e.useInsightsAccess=S,_e.SuperProInsights=_,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,D.jsx)(o.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,D.jsx)(_,{go:e})}):(0,D.jsx)(E,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.sales)return(0,D.jsx)(E,{});const r=i.sales;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Last 7 days"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=r.last7?(0,x.moneyGbp)(r.last7):'\u2014'}),r.missing7?(0,D.jsx)(l.Muted,{center:!0,children:`From ${r.days7} of ${r.days7+r.missing7} cash ups. ${r.missing7} ha${1===r.missing7?'s':'ve'} no card or cash total yet, so ${1===r.missing7?'it is':'they are'} not in the total.`}):null,(0,D.jsx)(l.Muted,{center:!0,children:null!=r.prev7?`The 7 days before: ${(0,x.moneyGbp)(r.prev7)}${null!=r.changePct?` (${r.changePct>=0?'up':'down'} ${Math.abs(r.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,D.jsx)(l.Muted,{center:!0,children:null!=r.sph7?`Spend per head ${(0,x.moneyGbp)(r.sph7)}, on the ${r.sphDays7} day${1===r.sphDays7?'':'s'} with takings and Covers`:'Spend per head shows once days have takings and Covers'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Takings by week"}),(0,D.jsx)(O,{values:r.weeks.map(e=>e.gross),w:300,h:70}),r.weeks.slice().reverse().map(e=>(0,D.jsx)(W,{a:`${(0,w.ukDate)(e.from)} \u2013 ${(0,w.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up${e.missing?`, ${e.missing} with no card or cash total`:''}`:e.missing?`Not enough data: ${e.missing} cash up${1===e.missing?'':'s'} with no card or cash total`:'No signed-off cash ups'},e.to)),(0,D.jsx)(l.Muted,{center:!0,children:"Takings are card + cash \u2212 card tips from signed-off cash ups (Gross only for a prepaid function), as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,D.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.stock)return(0,D.jsx)(E,{});const r=i.stock;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Low or out now"}),(0,D.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."}),r.low.length?r.low.map(e=>(0,D.jsx)(W,{testID:`low-${e.key}`,tone:e.out?k.colours.red:k.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,D.jsx)(l.Muted,{center:!0,children:r.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:`Price rises in the last ${w.RISE_DAYS} days`}),r.rises.length?r.rises.map(e=>(0,D.jsx)(W,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,$.gbp)(e.before)} \u2192 ${(0,$.gbp)(e.after)} a pack \xb7 ${(0,w.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,D.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,D.jsx)(l.Muted,{center:!0,children:r.lastCount?`Last full stock count ${(0,w.ukDate)(r.lastCount)}.`:'No full stock count yet.'})]}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.gp)return(0,D.jsx)(E,{});const r=i.gp;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,D.jsx)(A,{example:i.example}),i.example?(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:k.colours.gold,children:L(r.menu)}),null!=r.startMenu&&null!=r.menu?(0,D.jsx)(l.Muted,{center:!0,children:`${G(r.menu-r.startMenu)} points since ${(0,w.ukDate)(r.trend[0]?.week??'')}`}):null,(0,D.jsx)(O,{values:r.trend.map(e=>e.menu),w:300,h:80})]}):null!=r.menu?(0,D.jsx)(v.GpOverTime,{rid:s}):(0,D.jsx)(o.default,{testID:"insights-gp-not-enough",style:{width:'100%'},children:(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP"}),(0,D.jsx)(l.T,{weight:"semibold",center:!0,children:"Not enough data"}),(0,D.jsx)(l.Muted,{center:!0,children:`${r.fullyCosted} of ${r.costed} costed dishes have every recipe ingredient costed. Menu GP shows once ${w.MIN_FULLY_COSTED} or more are, so a part-costed dish cannot make GP look too high.`})]})}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),r.drops.length?r.drops.map(e=>(0,D.jsx)(W,{testID:`drop-${e.dishId}`,tone:k.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,w.ukDate)(e.date)}`},e.dishId)):(0,D.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Each dish over 3 months"}),r.dishes.length?r.dishes.map(e=>(0,D.jsx)(W,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const s=S(),n=C(),{list:i,source:r}=N(),[a,d]=(0,t.useState)('all');if(!s.clock)return(0,D.jsx)(E,{});const c='unsigned'===a?i.filter(e=>!1===e.signed):i,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,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,D.jsx)(A,{example:!!n}),(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${i.length})`,onPress:()=>d('all'),testID:"clock-filter-all"}),(0,D.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${i.filter(e=>!1===e.signed).length})`,onPress:()=>d('unsigned'),testID:"clock-filter-unsigned"})]}),(0,D.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:c.length?c.map(e=>(0,D.jsxs)(o.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${w.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,w.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:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?k.colours.amber:k.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,w.ukDate)(e.workDate)}`}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,children:`${w.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,D.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,D.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,D.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,D.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${w.CLOCK_DAYS} days.`})}),(0,D.jsx)(l.Muted,{center:!0,children:'server'===r?'From the server\u2019s timesheet audit.':'synced'===r?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=_r(_d[1]),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=e(i),l=_r(_d[5]),a=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),$=_r(_d[15]),x=_r(_d[16]),w=_r(_d[17]),b=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),D=_r(_d[23]);const P='SuperPro';function S(){const{role:e}=(0,j.useCtx)(6e4),s=(0,j.useSignedIn)(),t=(0,j.useInStaffApp)();return(0,w.insightsAccess)({viewRole:e,signed:s,live:(0,b.isLive)(),inStaffApp:t,perm:e=>(0,b.can)(e)})}function C(){return(0,y.useExamples)()&&!(0,b.isLive)()?I.INSIGHTS_SAMPLE:null}function N(){const e=C(),s=(0,h.useOwner)(e=>e.attendance),n=(0,h.useOwner)(e=>e.staff),[o,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(e||!(0,b.isLive)())return;let s=!0;return(0,b.readClockChanges)(w.CLOCK_DAYS).then(e=>{s&&e&&i((0,w.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,t.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const t=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:t(o),source:'server'};const i=(0,w.addDaysYmd)((new Date).toISOString().slice(0,10),-w.CLOCK_DAYS);return{list:t((0,w.clockChangesFromAttendance)(s,i)),source:'synced'}},[e,o,s,n])}function M(e){const s=C(),[n,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(s||!e||!(0,b.isLive)())return;let t=!0;return(0,b.readLoyaltyInsight)().then(e=>{t&&o(e?(0,w.loyaltyInsight)(e.raw,e.source):null)}),()=>{t=!1}},[s,e]),s?s.loyalty:e&&(0,b.isLive)()?n:null}function T(e,n){const o=C(),i=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,a.useBookings)(e),y=(0,a.useOrders)(e),$=(0,d.useReviews)(e=>e.reviews),x=(0,h.useOwner)(e=>e.attendance),b=(0,j.useHourly)(),k=(0,u.useGpCalcView)(),v=(0,a.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),D=(0,g.useShellStore)((0,f.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,t.useMemo)(()=>{if(o)return{example:!0,...o};const t=v.map(e=>({id:e.id,dish:e.dish,price:e.price,ingCount:Array.isArray(e.ingredients)?e.ingredients.length:void 0})),a=new Date,d=(0,w.salesInsight)(i,l,e,n,(0,s.coverOverridesFor)(e)),c=x.filter(e=>!e.voided&&'confirmed'===(0,h.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,j.paidMins)(e,a).paid,ratePence:b[e.staffId]??0})),u=x.filter(e=>!e.voided&&'awaiting'===(0,h.attStatus)(e)).map(e=>e.date);return{example:!1,sales:d,stock:(0,w.stockInsight)((I??[]).filter(e=>!e.group),D,(s,t)=>(0,p.fmtStockCount)(e,s,t),k.ingredients,Object.values(k.counts??{}),n),gp:(0,w.gpInsight)(k.ingredients,k.cardCosts??{},t,k.settings,Object.values(k.deliveries??{}),n),bookings:(0,w.bookingsInsight)(l,e,n),orders:(0,w.ordersInsight)(y,e,n),reviews:(0,w.reviewsInsight)($,e,n),labour:(0,w.labourInsight)(c,i,e,n,u),salesReport:(0,w.salesReportInsight)(r,e)}},[o,i,r,l,y,$,x,b,e,n,k,v,I,D])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,G=e=>`${e>0?'+':''}${e.toFixed(1)}`;function O({values:e,w:s=220,h:t=44,testID:n}){const l=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(l.length<2)return null;const a=Math.min(...l.map(e=>e.v)),d=Math.max(...l.map(e=>e.v))-a||1,c=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/d*(t-12),h=l[l.length-1];return(0,D.jsx)(o.default,{testID:n,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,D.jsxs)(r.default,{width:s,height:t,children:[(0,D.jsx)(i.Polyline,{points:l.map(e=>`${c(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:k.colours.gold,strokeWidth:2.5,fill:"none"}),(0,D.jsx)(i.Circle,{cx:c(h.i),cy:u(h.v),r:3.5,fill:k.colours.gold})]})})}function R({title:e,big:s,line:t,tone:o,onPress:i,testID:r,children:a,a11y:d,plan:c}){return(0,D.jsxs)(n.default,{testID:r,accessibilityRole:"button",accessibilityLabel:d,accessibilityHint:"Opens the detail",onPress:i,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??k.colours.gold,backgroundColor:e?k.colours.goldTint:k.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:e}),c?(0,D.jsx)(l.T,{size:11,weight:"semibold",colour:k.colours.goldLight,center:!0,children:c.toUpperCase()}):null,(0,D.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??k.colours.text,children:s}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.muted,children:t}),a,(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.goldLight,children:"Open \u203a"})]})}function A({example:e}){return(0,D.jsxs)(o.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.T,{size:20,weight:"bold",colour:k.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,D.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,D.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function B({title:e,sub:s,children:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.Badge,{kind:"gold",label:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]}),(0,D.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function _({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t),r=N(),l=M(n.loyalty);if(!n.any)return null;const a=(0,w.clockSummary)(r.list),d=(0,w.loyaltyLine)(l),c=s=>e('more',s),u=i.sales,h=i.stock,g=i.gp,p=i.bookings,f=i.orders,y=i.reviews,b=i.labour,v=i.salesReport,I=e=>w.INSIGHT_PLAN[e],C=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=n.sales||n.stock||n.gp||n.clock,E=n.bookings||n.noshows||n.orders||n.loyalty||n.reviews||n.labour||n.salesReports;return(0,D.jsxs)(o.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,D.jsx)(A,{example:i.example}),_?(0,D.jsxs)(B,{testID:"insights-group-superpro",title:P,sub:"Connected EPOS insights",children:[n.sales?(0,D.jsx)(R,{plan:I('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>c('insights-sales'),big:C(u.last7),line:null==u.last7?u.missing7?`Not enough data: ${u.missing7} cash up${1===u.missing7?'':'s'} in the last 7 days ha${1===u.missing7?'s':'ve'} no card or cash total`:'No signed-off cash ups in the last 7 days':`Last 7 days, card + cash \u2212 card tips from ${u.days7}${u.missing7?` of ${u.days7+u.missing7}`:''} cash-up day${u.days7+u.missing7===1?'':'s'}${u.missing7?` (${u.missing7} with no card or cash total)`:''}${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)}`:u.missing7?'Not enough data, the cash ups have no card or cash total':'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,D.jsx)(O,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,n.stock?(0,D.jsx)(R,{plan:I('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>c('insights-stock'),tone:h.low.length?k.colours.amber:void 0,big:h.low.length?`${h.low.length} low`:h.tracked?'None low':'\u2014',line:`${h.low.length?h.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):h.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${h.rises.length} price rise${1===h.rises.length?'':'s'} in ${w.RISE_DAYS} days`,a11y:`Stock. ${h.low.length} tracked items low or out. ${h.rises.length} price rises in ${w.RISE_DAYS} days`}):null,n.gp?(0,D.jsx)(R,{plan:I('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>c('insights-gp'),tone:g.drops.length?k.colours.amber:void 0,big:null==g.menu?'\u2014':L(g.menu),line:null==g.menu?`Not enough data: ${g.fullyCosted} of ${g.costed} costed dishes have every ingredient costed`:`Menu GP, ${g.fullyCosted} fully costed dishes${null!=g.startMenu?` \xb7 ${G(g.menu-g.startMenu)} pts in 3 months`:''} \xb7 ${g.drops.length} dish${1===g.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(g.menu)}. ${g.drops.length} dishes fell after a cost change`,children:(0,D.jsx)(O,{testID:"insight-gp-spark",values:g.trend.map(e=>e.menu)})}):null,n.clock?(0,D.jsx)(R,{plan:I('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>c('insights-clock'),tone:a.unsigned?k.colours.amber:void 0,big:String(a.total),line:`Edits in ${w.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 ${w.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,D.jsxs)(B,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[n.salesReports?(0,D.jsx)(R,{plan:I('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:C(v.gross),line:v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}${v.top.length?` \xb7 ${v.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}, ${C(v.gross)}`:'None yet')}):null,n.bookings?(0,D.jsx)(R,{plan:I('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,n.noshows?(0,D.jsx)(R,{plan:I('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?k.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}${n.sales?` (${(0,$.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,n.orders?(0,D.jsx)(R,{plan:I('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,$.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,n.reviews?(0,D.jsx)(R,{plan:I('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:y.low30?k.colours.amber:void 0,big:null!=y.avg30?`${y.avg30.toFixed(1)} \u2605`:'\u2014',line:`${y.count30} review${1===y.count30?'':'s'} in 30 days \xb7 ${y.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${y.avg30??'none'} stars from ${y.count30} reviews in 30 days`}):null,n.loyalty?(0,D.jsx)(R,{plan:I('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:d.big,line:d.line,a11y:`Loyalty. ${l?.members??'Not known'} members. ${l?.stampsMonth??'Not known'} stamps this month. ${l?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,n.labour?(0,D.jsx)(R,{plan:I('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=b.pct7&&b.pct7>35?k.colours.amber:void 0,big:null!=b.pct7?`${b.pct7}%`:'\u2014',line:null!=b.pct7?`Wages of takings on the ${b.days7} day${1===b.days7?'':'s'} with takings, last 7 days \xb7 ${C(b.labour7)} wages`:`Not enough data: no day in the last 7 has both signed-off hours and takings \xb7 ${b.paidHours7} signed-off hours`,a11y:`Wages and hours versus takings. ${b.pct7??'Not known'} percent over 7 days, ${b.paidHours7} hours`}):null]}):null]})}function E(){return(0,D.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function W({a:e,b:s,tone:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]})}},1464,[1465,17,385,85,780,777,858,1242,1008,905,876,895,897,864,1145,851,1466,1468,899,804,1057,1179,1469,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"coverOverridesFrom",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"coverOverridesFor",{enumerable:!0,get:function(){return c}});var o=r(_d[0]);const t={anchorage:{'2026-11-09':{covers:50,why:'BBC function, prepaid, 50 people (Gordon, 25 Nov 2026)'}}},n=(o,n)=>n?Object.fromEntries(Object.entries(t[o]??{}).map(([o,t])=>[o,t.covers])):{},c=t=>n(t,o.LIVE_VENUE_BUILD)},1465,[822]); -__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=l,_e.previousRange=function(e,n){const o=l(e,n);if('today'===n||'week'===n)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===n?1:0)-('today'===n?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===n?1:0)-('today'===n?1:0))};const[r,s]=o.from.split('-').map(Number),u=`${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=`${u.slice(0,7)}-${o.to.slice(8,10)}`;return{from:u,to:d<=c&&d>=u?d:c}},_e.changePct=function(t,e){return null==t||null==e||0===e?null:Math.round((t-e)/e*1e3)/10},_e.changeWords=function(t,e){if(null==t)return null;const n='today'===e?'yesterday':'week'===e?'last week':'last month';return 0===t?`No change vs ${n}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${n}`},_e.canSeeTakingsStats=function(t,e,n){return!('owner'!==t&&'manager'!==t||e&&!n)},_e.coversInRange=function(t,e){let s=0,l=0;for(const u of t){if(!u.date||!n(u.date,e))continue;if(!r(u.status))continue;const t=u.partySize||0;o(u)?s+=t:l+=t}const u=s+l;if(!u)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/u*100);return{total:u,walkIns:s,bookings:l,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,e,r){const l=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t)&&(s(t.status)||'noshow'===t.status));if(!l.length)return{rate:null,count:0,of:0,empty:!0};const u=l.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/l.length*1e3)/10,count:u,of:l.length,empty:!1}},_e.cancelRate=function(t,e,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const l=s.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(l/s.length*1e3)/10,count:l,of:s.length,empty:!1}},_e.takingsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{gross:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{gross:null,days:0,missing:u.length,missingDates:u}},_e.grossDays=u,_e.tipsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.combinedTips)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{tips:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{tips:null,days:0,missing:u.length,missingDates:u}},Object.defineProperty(_e,"completeTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"missingWords",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"takingsMissingWords",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return g}}),_e.tipsVsTakings=function(e,o,r){let s=0,l=0,u=0;for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals),d=(0,t.combinedTips)(c.vals);null==e||null==d||e<=0||(s+=d,l+=e,u+=1)}return u?{pct:g(Math.round(100*s)/100,Math.round(100*l)/100),days:u}:{pct:null,days:0}},_e.spendPerHeadInRange=function(t,n,o,r,s={}){const l=[...u(t,o,r).entries()].map(([t,r])=>({date:t,gross:r,covers:(0,e.coversOn)(n,o,t)+(s[t]??0)})),c=l.filter(t=>t.covers>0),d=l.length-c.length;if(!c.length)return{sph:null,covers:0,gross:null,days:0,noCovers:d};const f=Math.round(100*c.reduce((t,e)=>t+e.gross,0))/100,g=c.reduce((t,e)=>t+e.covers,0);return{sph:Math.round(f/g*100)/100,covers:g,gross:f,days:c.length,noCovers:d}},_e.labourCostInRange=h,_e.labourVsTakings=function(t,e,n,o,r){const s=u(n,o,r),l=s.size?Math.round(100*[...s.values()].reduce((t,e)=>t+e,0))/100:null,c=s.size?h(t,r,s):null;return{pct:m(c,l),labour:c,gross:l,days:s.size,awaiting:e.filter(t=>s.has(t)).length,labourAll:h(t,r)}},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return m}}),_e.repeatGuestPct=function(t,e,o){const r=new Set;for(const n of t){if(o&&n.restaurantId!==o)continue;if(!s(n.status)||n.date>=e.from)continue;const t=p(n);t&&r.add(t)}const l=new Set;let u=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!n(d.date,e))continue;const t=p(d);t&&!l.has(t)&&(l.add(t),u+=1,r.has(t)&&(c+=1))}return u?{rate:Math.round(c/u*1e3)/10,count:c,of:u,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.firstVisitDate=function(t,e){let n=null;for(const o of t)e&&o.restaurantId!==e||!s(o.status)||!o.date||(!n||o.date(null==t.status||'published'===t.status)&&n(t.createdAt.slice(0,10),e)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,e)=>t+e.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"NOT_SHOWN_YET",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return e.coversOn}});var t=_r(_d[0]),e=_r(_d[1]);const n=(t,e)=>t>=e.from&&t<=e.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function l(e,n){return'today'===n?{from:e,to:e}:'week'===n?{from:(0,t.weekStartOf)(e),to:e}:{from:`${e.slice(0,7)}-01`,to:e}}function u(e,o,r){const s=new Map;for(const l of e){if(l.rid!==o||!l.confirmedAt||!n(l.date,r))continue;const e=(0,t.tillTakingsOf)(l.vals);null!=e&&s.set(l.date,e)}return s}const c=(t,e)=>t.missing?null:e,d=(t,e,n)=>`Not enough data: ${t} cash up${1===t?' has':'s have'} no ${e} yet (${n.map(v).join(', ')})`,f=t=>`${t.length} cash up${1===t.length?' has':'s have'} no card or cash total yet (${t.map(v).join(', ')}), so ${1===t.length?'it is':'they are'} not in the total`,g=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function h(t,e,o){let r=0,s=!1;for(const l of t)!n(l.date,e)||l.ratePence<=0||l.paidMins<=0||o&&!o.has(l.date)||(r+=l.paidMins/60*l.ratePence,s=!0);return s?Math.round(r)/100:null}const m=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function p(t){const e=(t.phone||'').replace(/\s+/g,'').toLowerCase(),n=(t.email||'').trim().toLowerCase();return e.length>=7?`p:${e}`:n.includes('@')?`e:${n}`:null}const y='Not shown yet: GP and food cost %, table occupancy and top dishes. They need till sales, which CoverCharge does not have yet.',b={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.'},k=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,v=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,w=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1466,[839,1467]); -__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,u={}){const l=(0,r.weekStartOf)(o);return Array.from({length:d},(f,h)=>{const m=(0,r.addDaysYmd)(l,7*(h-d+1)),p=i(n,t,s,(0,r.addDaysYmd)(m,6),7,u).filter(r=>r.date<=o&&null!=r.gross),v=p.length?Math.round(100*p.reduce((r,n)=>r+n.gross,0))/100:null,y=p.reduce((r,n)=>r+n.covers,0);return{weekStart:m,gross:v,covers:y,days:p.length,sph:c(v,y)}})},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,l={}){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,h)=>{const m=(0,r.addDaysYmd)(o,h-i+1),p=f.get(m)?.vals??{},v=(0,r.tillTakingsOf)(p),y=d(t,s,m)+(l[m]??0),b=u(p.food),k=u(p.drink);return{date:m,gross:v,covers:y,sph:c(v,y),food:b,drink:k,foodPh:c(b,y),drinkPh:c(k,y)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.tillTakingsOf)(n.vals))},1467,[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=d,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return c}}),_e.salesInsight=function(e,t,r,o,s={}){const a={from:d(o,-6),to:o},i={from:d(o,-13),to:d(o,-7)},l=(0,n.takingsInRange)(e,r,a),c=(0,n.takingsInRange)(e,r,i),u=(0,n.spendPerHeadInRange)(e,t,r,a,s),f=u.sph,g=[];for(let t=7;t>=0;t--){const s=d(o,-7*t),a=d(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});g.push({from:a,to:s,gross:i.gross,days:i.days,missing:i.missing})}const p=null!=l.gross&&null!=c.gross&&c.gross>0&&!l.missing&&!c.missing?Math.round((l.gross-c.gross)/c.gross*1e3)/10:null;return{last7:l.gross,prev7:c.gross,changePct:p,days7:l.days,missing7:l.missing,sphDays7:u.days,sph7:f,weeks:g,empty:g.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=d(s,-30),c=[];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&&c.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})}c.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:c,lastCount:u?.date??null,empty:!a.length&&!c.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"MIN_FULLY_COSTED",{enumerable:!0,get:function(){return g}}),_e.fullyCostedIds=p,_e.gpInsight=function(n,r,o,s,a,i){const l=p(n,r,o,s),c=o.filter(e=>(r[e.id]?.lines?.length??0)>0).length;if(l.sizel.has(e.id)),f=(0,e.menuGp)(n,r,u,s),m=(0,e.gpHistory)(a,f,'3m',i),h=m.points.find(e=>null!=e.menu)?.menu??null,b=f.dishes.map(e=>{const t=m.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)),k=(0,t.marginDrops)(a,d(i,-14)).filter(e=>u.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{fullyCosted:l.size,costed:c,menu:f.menu,startMenu:h,trend:m.points.map(e=>({week:e.week,menu:e.menu})),dishes:b,drops:k,underTarget:f.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?b(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return y(n)},_e.clockChangesFromServer=function(e){return y(e.filter(e=>h.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:k(e.action,e.old_value),after:k(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 w}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:d(r,-6),to:r},a={from:d(r,-13),to:d(r,-7)},i={from:d(r,-29),to:r},l=(0,n.coversInRange)(o,s),c=(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:c.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=d(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:d(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,o,s=[]){const a={from:d(o,-6),to:o},i=(0,n.labourVsTakings)(e,s,t,r,a),l=e.filter(e=>e.date>=a.from&&e.date<=a.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:i.labour,takings7:i.gross,pct7:i.pct,days7:i.days,paidHours7:Math.round(l/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=v(e.members),r=v(e.stampsMonth),o=v(e.rewardsUsedMonth??e.rewardsMonth),s=v(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 d(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 c=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14,g=5;function p(e,n,r,o){const s=new Set;for(const a of r){const r=n[a.id];if(!r||!r.lines?.length)continue;if(null==a.ingCount||r.lines.length0||i.priceIsSuggested||s.add(a.id)}return s}const m={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'},h=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),b=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 k(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:b(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const y=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const w=30;const v=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1468,[908,906,1466]); -__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},1469,[]); -__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.useAssistantRequestInbox=x,_e.AssistantRequestsButton=function({go:e,testID:t}){const{visible:s,count:l}=x();return s?(0,b.jsx)(n.default,{style:{width:'100%',maxWidth:900,alignSelf:'center',paddingHorizontal:14,paddingTop:4,paddingBottom:8},children:(0,b.jsx)(o.Button,{testID:t??'assistant-requests-btn',label:l?`Assistant requests \xb7 ${l}`:'Assistant requests',accessibilityLabel:(0,p.assistantRequestsButtonLabel)(l),accessibilityHint:"Opens the list of changes your assistant has asked you to confirm or decline",kind:l?'primary':'secondary',onPress:()=>e('more','assistant-requests'),style:{minHeight:56}})}):null},_e.AssistantRequestsPage=function(){const{rows:e,load:t,visible:s}=x();if(!s)return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner can confirm or decline assistant changes, and only when an assistant is paired."})]});return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{gap:12,paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Each change waits for an owner to approve or decline it. Important changes ask a second time."}),(0,b.jsx)(w,{rows:e,onChanged:()=>{t()}})]})},_e.AssistantPendingCard=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(null),c=async()=>{try{r(await(0,l.assistantProposalsList)())}catch{r([])}};return(0,t.useEffect)(()=>{if(!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR)return;c();const t=setInterval(()=>{c()},2e4);return()=>clearInterval(t)},[e,s,n]),!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR?null:(0,b.jsx)(w,{rows:o,onChanged:()=>{c()},compact:!0})},_e.AssistantsPage=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),[s,r]=(0,t.useState)(''),[u,h]=(0,t.useState)(null),[p,x]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[A,I]=(0,t.useState)(null),[k,D]=(0,t.useState)(null),[C,S]=(0,t.useState)(null),[T,P]=(0,t.useState)(null),L=async()=>{try{P(await(0,l.assistantAccess)())}catch{P({plan:null,allowed:!1,reason:'Could not check this plan.'})}try{v(await(0,l.assistantList)())}catch{v([])}try{I(await(0,l.assistantProposalsList)())}catch{I([])}try{D(await(0,l.assistantAuditList)())}catch{D([])}};(0,t.useEffect)(()=>{e&&L()},[e]);const R=s.replace(/\D/g,''),$=!!T?.allowed,M=async()=>{x(!0),h(null);const e=await(0,l.assistantApprove)(R);x(!1),e.ok?(r(''),h({ok:!0,text:'Done. The assistant is paired. It can look things up and propose changes, which wait for an owner to confirm on their phone.'}),L()):h({ok:!1,text:e.message})},q=async(e,t)=>{x(!0),h(null);const s=await(0,l.assistantSetEnabled)(e.id,t);x(!1),s.ok?(h({ok:!0,text:t?`${e.label} is switched on.`:`${e.label} is switched off. It stays paired, and you can switch it on again.`}),L()):h({ok:!1,text:s.message})};return(0,b.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,b.jsx)(w,{rows:A,onChanged:()=>{L()}}):null,(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair your assistant"}),(0,b.jsx)(o.T,{center:!0,children:f}),(0,b.jsx)(o.T,{center:!0,children:"Ask your assistant, such as Grok Bot, to start CoverCharge sign-in. It will show 6 numbers. Only an owner of this venue can approve it. In the connected assistant it can answer questions about your venue and give advice from the data it is allowed to look up. It can propose a change; nothing is changed until an owner confirms it on their 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 a second time, with a plain warning of what is affected."}),!$&&T?(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-plan-blocked",children:T.reason||'Connecting an AI assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.'}):null,(0,b.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:s,onChangeText:e=>r(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,b.jsx)(o.Button,{testID:"assistant-approve",label:p?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs your AI assistant with this venue",disabled:!e||!$||p||6!==R.length,onPress:()=>{M()},style:{minHeight:56}}),e?null:(0,b.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,b.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!u,accessibilityLabel:u?.text,children:u?(0,b.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:u.ok?c.colours.goldLight:c.colours.amber,children:u.text}):null}),(0,b.jsx)(o.Muted,{center:!0,children:"Never send a personal app link to the bot. That link stays on your phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, it cannot read other venues, and it cannot change its own access or pairing."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(t=>(0,b.jsxs)(n.default,{testID:`assistant-row-${t.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:`${t.label} \xb7 ${!1===t.enabled?'switched off':'paired'}`}),(0,b.jsx)(o.Muted,{center:!0,children:`Since ${y(t.approvedAt)}. Last seen ${y(t.lastSeenAt)}.${t.ownerName?` Tied to ${t.ownerName}.`:''}`}),(0,b.jsx)(o.Toggle,{testID:`assistant-enabled-${t.id}`,label:"Assistant on",value:!1!==t.enabled,disabled:p||!e,onChange:e=>{q(t,e)},a11y:!1===t.enabled?`Switch on ${t.label}`:`Switch off ${t.label}`}),(0,b.jsx)(o.Button,{testID:`assistant-revoke-${t.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${t.label}`,onPress:()=>S(t),style:{minHeight:56}})]},t.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Activity log"}),(0,b.jsx)(o.Muted,{center:!0,children:"Everything this venue\u2019s assistants do is logged here, including look-ups. The assistant cannot change or skip this log."}),null===k?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):k.length?k.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-audit-${e.id}`,style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:e.detail||e.action}),(0,b.jsx)(o.Muted,{center:!0,children:`${y(e.at)}${e.actorName?` \xb7 ${e.actorName}`:''}`})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-audit-empty",children:"No activity yet."})]}),C?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>S(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,b.jsx)(o.T,{center:!0,children:`${C.label} stops working straight away. Any changes still waiting are cancelled. Your phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,b.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=C;S(null);const t=await(0,l.assistantRevoke)(e.id);h(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),L()},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>S(null),style:{minHeight:56}})]}):null]})};var t=_r(d[0]),s=e(_r(d[1])),n=e(_r(d[2])),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]);const y=e=>e?`${(0,r.niceDate)(new Date(e))} at ${(0,r.hm)(new Date(e))}`:'not yet',f='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.';function w({rows:e,onChanged:r,compact:u}){const h=(e??[]).filter(e=>'pending'===e.status),[f,w]=(0,t.useState)(null),[x,j]=(0,t.useState)(null),[v,A]=(0,t.useState)(null),I=async(e,t,n=!1)=>{w(e.id),j(null);const o=await(0,l.assistantProposalDecide)(e.id,t,n);if(w(null),o.ok){A(null);const e='decline'===t?'Declined. Nothing was changed.':'Done. The change has been made.';j(e),s.default.announceForAccessibility(e),r?.()}else j(o.message),s.default.announceForAccessibility(o.message)};return!h.length&&u?null:(0,b.jsx)(n.default,{testID:u?'assistant-pending-home':'assistant-pending-list',children:(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Waiting for an owner to confirm"}),e?h.length?h.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:8,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,alignItems:'center'},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,b.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${y(e.expiresAt)}.`:'']}):e.expiresAt?(0,b.jsx)(o.Muted,{center:!0,children:`Runs out at ${y(e.expiresAt)}.`}):null,e.canDecide?(0,b.jsxs)(n.default,{style:{gap:8,width:'100%',maxWidth:520,alignSelf:'center'},children:[(0,b.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:f===e.id?'Working\u2026':'Approve',accessibilityLabel:(0,p.assistantRequestActionLabel)('Approve',e.summary),accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!f,onPress:()=>{e.needsDoubleConfirm?A(e):I(e,'approve')},style:{minHeight:56}}),(0,b.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",accessibilityLabel:(0,p.assistantRequestActionLabel)('Decline',e.summary),disabled:!!f,onPress:()=>{I(e,'decline')},style:{minHeight:56}})]}):(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner of this venue can confirm or decline this on their phone."})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,b.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),(0,b.jsx)(n.default,{accessible:!0,accessibilityLiveRegion:"polite",accessibilityRole:"text",testID:"assistant-requests-status",style:{minHeight:x?void 0:0},children:x?(0,b.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:x}):null}),v?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>A(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,b.jsx)(o.T,{center:!0,accessibilityRole:"header",children:v.summary}),(0,b.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."}),v.warning?(0,b.jsx)(o.Muted,{center:!0,children:v.warning}):null,(0,b.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:f===v.id?'Working\u2026':'Yes, make this change',disabled:!!f,accessibilityLabel:`Yes, make this change: ${v.summary}`,onPress:()=>{I(v,'approve',!0)},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Go back",accessibilityLabel:`Go back without changing: ${v.summary}`,onPress:()=>A(null),style:{minHeight:56}})]}):null]})})}function x(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(0),[c,b]=(0,t.useState)(null),y=async()=>{try{const[e,t]=await Promise.all([(0,l.assistantList)(),(0,l.assistantProposalsList)()]);r((e??[]).length),b(t??[])}catch{r(0),b([])}};(0,t.useEffect)(()=>{if('owner'!==u.APP_VARIANT||u.IS_CAR||n||'owner'!==s||!e)return;y();const t=setInterval(()=>{y()},2e4);return()=>clearInterval(t)},[e,s,n]);const f=(c??[]).filter(e=>'pending'===e.status).length;return{visible:(0,p.canSeeAssistantRequests)({appVariant:u.APP_VARIANT,isCar:u.IS_CAR,inStaffApp:n,role:s,live:e,pairedCount:o}),count:f,rows:c,load:y,paired:o}}},1470,[17,264,85,777,899,863,804,856,1057,1471,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.assistantRequestActionLabel=function(t,s){const n=String(s||'this change').replace(/\s+/g,' ').trim().replace(/\.+$/,'');return`${t}: ${n||'this change'}`},e.assistantRequestsButtonLabel=function(t){const s=Math.max(0,Math.floor(Number(t)||0));return 1===s?'Assistant requests, 1 waiting':`Assistant requests, ${s} waiting`},e.canSeeAssistantRequests=function(t){return'owner'===t.appVariant&&!t.isCar&&!t.inStaffApp&&'owner'===t.role&&!!t.live&&(t.pairedCount??0)>0}},1471,[]); -__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"})]})}},1472,[817,1189,17,264,266,347,378,219,278,85,19,777,857,860,876,998,1036,1037,805,842,1034,1473,804,856,1057,1474,1477,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}}},1473,[1034]); -__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=C,_e.importQuestionnaireAccounts=B,_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. 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)(i.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:l}=(0,x.useCtx)(6e4),j='owner'===n,I=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],M=(0,p.useQuestionnaire)(e),{mark:P}=(0,p.useProvenance)(e),[A,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(M?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!I.some(n=>n.provider===e.provider)),[M,I]),W=(M?.accounts??[]).some((e,n)=>P('accounts',n,'provider'));return(0,y.jsxs)(i.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)(i.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:P('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:l})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>M&&B(e,M,l)}):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:`${I.length}`})]}),I.length?I.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(M?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(i.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)(i.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:P('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:T[e.status].kind,label:T[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)(C,{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=I.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:A,owner:j,by:l,onClose:()=>z(null)}),$?(0,y.jsx)(k,{rid:e,c:$,by:l,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),l=e(r(d[4])),i=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)(i.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 C({rid:e,compact:n}){const{role:o,me:l}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,C]=(0,t.useState)({}),[B,I]=(0,t.useState)(null),T=u.useAccounts.getState();return(0,y.jsxs)(i.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)(i.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)(i.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)(i.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)(i.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>C({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(i.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:()=>T.update(e,o.id,{accountNo:u},l,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>I(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>T.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:l})})}),(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)}),B?(0,y.jsx)(k,{rid:e,c:B,by:l,onClose:()=>I(null)}):null]})}function k({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)(i.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:["CoverCharge will stop listing ",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 B(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const l of n.accounts??[])o.some(e=>e.provider===l.provider)||s.add(e,{provider:l.provider,handle:l.handle,status:'listed',from:'questionnaire',addedBy:t})}function I({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,C]=(0,t.useState)(p?.handle??''),[k,B]=(0,t.useState)(p?.customName??''),[I,T]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const M=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${M?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(l.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(i.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:M?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),M?(0,y.jsx)(a.Field,{label:"Service name",value:k,onChangeText:B,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:()=>T(!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."]})]}),I?(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, 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:C,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:M?'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:M&&k.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:M?k.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:M&&!k.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)(i.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)(i.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)(i.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 T={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)(I,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1474,[812,17,362,385,278,85,777,1475,1476,804,1472,1057,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)},1475,[]); -__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)}))},1476,[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})]})}},1477,[17,385,85,777,860,1476,998,842,1478,1473,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'},1478,[]); -__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}},1479,[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])},1480,[1184,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1181,1443,1161,860,1185,853,1183,884,1360,998,843,1115,1198,1205,1071,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']}},1481,[17,1055,85,409,777,858,1141,1140,861,863,804,876,1183,1057,1148,1144,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}))},1482,[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]})]})}},1483,[805,1418,843,1392,17,85,777,858,860,866,845,851,1159,1105,863,804,1183,1057,1160,1161,853,1424,848,900,1484,8]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const a=!!e.settings.takeawayPaused;return(0,u.jsx)(l.Card,{highlight:a?r.colours.red:void 0,children:(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(l.T,{weight:"semibold",children:a?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,u.jsx)(l.Muted,{children:a?'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,u.jsx)(l.Toggle,{testID:"takeaway-pause",label:a?'Resume':'Pause',value:!a,onChange:a=>t.useStore.getState().updateSettings(e.id,{takeawayPaused:!a})})]})})},_e.TakeawayMenuList=function({me:e}){const[s,t]=(0,a.useState)(!1),c=(0,o.useStaffTakeaway)(e=>e.rows),h=(0,o.useStaffTakeaway)(e=>e.canSet),f=(0,o.useStaffTakeaway)(e=>e.busy),w=(0,o.useStaffTakeaway)(e=>e.error),y=(0,o.useStaffTakeaway)(e=>e.loadedAt);(0,a.useEffect)(()=>{s&&(0,o.loadStaffTakeaway)(!0)},[s]);const k=c?Object.values(c).sort((e,a)=>e.section.localeCompare(a.section)||e.dish.localeCompare(a.dish)):null,j=k?.filter(e=>e.onMenu).length??0,x=y>0&&null===c;return(0,u.jsxs)(l.Card,{children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",k?` \xb7 ${j} of ${k.length} available`:'']}),(0,u.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Hide':'Choose dishes',onPress:()=>t(!s),testID:"takeaway-menu"})]}),s?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(l.Muted,{children:"The whole menu shows on the takeaway page. Switch off what can\u2019t be done for takeaway today: guests see it as \u201cNot available for takeaway today\u201d. A dish also needs Head Chef allergen sign-off and a price."}),!h&&k?(0,u.jsx)(l.Muted,{children:"Only the Head Chef, a manager or an owner can change this."}):null,x?(0,u.jsx)(l.Banner,{kind:"warn",children:"Connect to the venue to see the takeaway menu."}):null,w?(0,u.jsx)(l.Banner,{kind:"warn",children:w}):null,k||x||w?null:(0,u.jsx)(l.Muted,{children:"Loading\u2026"}),(k??[]).map(a=>(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsxs)(l.T,{size:14,children:[a.dish,a.pricePence?` \xb7 ${(0,d.gbp)(a.pricePence)}`:'']}),(0,u.jsxs)(l.Row,{gap:4,children:['Specials board'===a.section?(0,u.jsx)(l.Badge,{kind:"gold",label:"Special"}):null,a.soldOut?(0,u.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,a.signedOff?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),a.pricePence?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),h?(0,u.jsx)(l.Toggle,{label:"Available for takeaway",a11y:`Available for takeaway, ${a.dish}`,value:a.onMenu,disabled:f===a.itemId,onChange:s=>{(0,o.setTakeawayAvailable)(a.itemId,s,e).catch(()=>{})}}):(0,u.jsx)(l.T,{size:14,colour:a.onMenu?r.colours.gold:r.colours.muted,children:a.onMenu?'Available':'Not today'})]},a.itemId))]}):null]})};var e,a=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),t=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),u=_r(_d[7])},1484,[17,85,777,858,851,1158,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 Ce}});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]),w=_r(d[16]),v=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),I=_r(d[22]),M=_r(d[23]),G=_r(d[24]),O=_r(d[25]),E=_r(d[26]),B=_r(d[27]),x=_r(d[28]),D=_r(d[29]),N=_r(d[30]),L=(e=N)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),q=_r(d[33]),Q=_r(d[34]),F=_r(d[35]),U=_r(d[36]),V=_r(d[37]),W=_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]),ye=_r(d[64]);const Ce=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},me=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:me,C:v.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=>me(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:me,C:O.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:me,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=>me(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:me,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:me,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:me,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:me,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:me,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:me,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:me,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:E.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:me,C:G.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:me,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:B.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:B.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:me,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:me,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:me,C:w.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:B.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:B.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:B.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:me,C:B.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:me,C:B.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:me,C:B.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:me,C:B.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:me,C:B.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:B.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:me,C:B.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:B.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:()=>Ce(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:me,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:me,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:me,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:me,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:me,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:me,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const Se=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(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:Se,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:Se,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:me,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:me,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:me,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:me,C:F.DisplaySettingsPage}]);const ke=e=>'owner'===e||'manager'===e;U.ASSISTANT_AVAILABLE&&V.ASSISTANT_UI&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:ke,C:U.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:ke,C:U.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:Y.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair your own AI assistant with a 6-digit code, switch it off, or unpair it',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantsPage}]),(0,y.register)([{id:'assistant-requests',title:'Assistant requests',sub:'Confirm or decline changes your assistant has proposed',group:'Start here',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantRequestsPage}]);const we=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:I.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:I.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:I.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:I.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:I.InsightsClockPage}]);const Pe=()=>{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)},Re=e=>we(e)&&Pe();(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:we,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:Re,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:Re,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:Re,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:we,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,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:we,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:me,C:z.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:me,C:z.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:me,C:z.Outbox}]);const Ae=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:Ae,C:J.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:J.optinsAllowed,C:J.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Ae,C:$.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Ae,C:K.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:Ae,C:X.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:Ae,C:Z.OrderSheetSettings},...ee.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Ae,C:(0,K.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Ae,C:te.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Ae,C:se.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:me,C:se.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Ae,C:se.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:Ae,C:ae.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:me,C:ie.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:me,C:ie.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:me,C:ie.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:me,C:re.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos and Show me where',group:'Start here',can:me,C:oe.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:me,C:ue.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:me,C:le.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:le.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ce.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ge.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:we,C:function(){const{rid:e,today:t}=(0,de.useCtx)(6e4);return L.default.createElement(ge.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(pe.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:me,C:ne.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(he.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:me,C:be.NightlyReportPage}]),(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:ye.UseOnComputerPage}]),(0,y.register)([{id:'support',title:'Customer support',sub:'Send a message or a picture to CoverCharge',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:fe.SupportChatPage}])},1485,[822,1050,856,1486,876,920,909,816,866,1488,1495,1497,1456,1498,1499,1501,1502,1160,1481,1503,1504,1505,1464,1201,1192,1483,1506,1454,1507,1508,17,1198,1181,1455,1443,1457,1513,1213,1519,1520,1470,1521,1446,1431,1522,1461,1523,886,1524,1525,1527,1187,1472,1528,1392,1474,1540,1081,1057,1202,1152,1544,1547,1550,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}),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)}},1486,[17,378,219,385,85,19,777,1026,1339,876,804,1487,1189,1482,1057,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}))},1487,[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}},1488,[812,1452,17,851,85,777,876,804,1057,884,885,1489,899,916,1031,1450,1490,1491,1493,996,1494,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},1489,[]); -__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])},1490,[812,17,85,777,804,876,1355,1354,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])},1491,[17,85,777,1492,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},1492,[831,928,899,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]},1493,[17,85,777,804,914,1022,899,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])},1494,[928,899]); -__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 h}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LINE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LITE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_TERM",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return C}}),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 U}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return $}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),h=(0,u.trialStatus)((0,l.defaultSimStart)(),e),[y,f]=(0,t.useState)(!1);return i.CAN.billing(n)?y?(0,p.jsx)(q,{onBack:()=>f(!1)}):(0,p.jsxs)(o.default,{style:{gap:10},children:[(0,p.jsx)(s.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,p.jsxs)(s.Card,{highlight:d.colours.gold,children:[(0,p.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,p.jsxs)(s.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[S,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-early-term",children:D})]}),(0,p.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:Y.map(([e,t])=>(0,p.jsxs)(o.default,{testID:e===b?'plan-early-guest-app':e===x?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,p.jsxs)(s.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,p.jsx)(s.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,p.jsx)(s.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,N,M,z,'Usual price',''],['plan-usual-pro',E,R,U,G,'Usual price',''],['plan-superpro',k,C,F,V,'1-year contract','No hardware included.']].map(([e,t,n,l,i,u,c])=>(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,p.jsxs)(s.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsx)(s.Muted,{center:!0,children:S}),(0,p.jsx)(s.Muted,{center:!0,children:l}),'plan-superpro'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-superpro-epos-line",children:B}):null,i.map(e=>(0,p.jsxs)(s.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),'plan-usual-lite'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-lite-ai",children:I}):null,c?(0,p.jsx)(s.Muted,{center:!0,children:c}):null]})},e)),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-terms",children:$}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>f(!0),style:{alignSelf:'center'}}),(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,p.jsxs)(s.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,p.jsx)(s.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,p.jsx)(s.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,p.jsx)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{children:"Free trial"}),(0,p.jsxs)(s.T,{weight:"bold",colour:d.colours.gold,children:[h.daysLeft," day",1===h.daysLeft?'':'s'," left"]})]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-h.daysLeft/h.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,p.jsxs)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'center'},gap:8,children:[(0,p.jsx)(s.T,{weight:"semibold",children:"Free customer support"}),(0,p.jsx)(s.Badge,{kind:"gold",label:"Included"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,p.jsx)(s.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},s=r(_d[2]),l=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]);const h=!0,y='Early adopter offer, usual prices, free trial, set-up guide',f='. 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',b='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',j='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',x='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.',_='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',v='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',I='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer.',O='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',S='+ VAT if applicable, per venue',L='Customer & Takeaway App',E='Full Restaurant Pro App',k='SuperPro',N='\xa349',R='\xa399',C='\xa3149',M='The lite version: core features for smaller venues.',U='Every feature, every app.',F='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',B='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.',D='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.',Y=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',D],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[b,A],['Free customer support','For the length of your subscription.'],[x,T],[v,v],[j,w]],z=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',b,P,j],G=['Owner dashboard and admin','Supplier links',x,v,b,P,j],V=['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',_,v,b,P,j],$='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. AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',K=[['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 q({onBack:e}){const[n,l]=(0,t.useState)([]);return(0,p.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,p.jsx)(s.H2,{children:"Set-up guide"}),(0,p.jsxs)(s.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",K.length," done."]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/K.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),K.map(([e,t],i)=>{const u=n.includes(i);return(0,p.jsx)(s.Card,{children:(0,p.jsxs)(s.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.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,p.jsx)(s.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,p.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(s.T,{weight:"semibold",children:e}),(0,p.jsx)(s.Muted,{children:t}),(0,p.jsx)(s.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>l(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,p.jsx)(s.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1495,[17,85,777,835,876,1496,804,1057,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'}},1496,[]); -__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]})]})]})}},1497,[805,1033,891,1418,813,812,822,1262,1438,17,385,393,85,864,777,858,876,845,851,863,804,1183,1057,1160,1443,1220,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])},1498,[843,17,85,1161,777,858,845,853,863,804,1183,1057,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])},1499,[1039,17,85,1500,814,857,777,876,804,1057,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}})},1500,[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])},1501,[17,1154,847,1057,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])},1502,[17,1032,1057,899,915,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])},1503,[17,1398,1057,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=b,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,u.useCtx)(6e4),n=(0,o.useBookings)(e),i=(0,d.useCashUp)(e=>e.cashUps),[j,w]=(0,s.useState)('day'),f=(0,h.hasAnyTakings)(i,e),k=(0,l.coverOverridesFor)(e),v=(0,h.dayRows)(i,n,e,t,14,k),$=(0,h.weekRows)(i,n,e,t,8,k),T=(0,h.averageSph)(v),S=(e,s,t,l,n)=>(0,p.jsxs)(a.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:c.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===l?'no takings entered':`spend per head ${l}`}, ${t}${n?`, ${n}`:''}`,children:[(0,p.jsx)(r.T,{center:!0,children:s}),(0,p.jsx)(r.T,{center:!0,colour:c.colours.muted,children:t}),(0,p.jsx)(r.T,{center:!0,weight:"semibold",colour:'No takings entered'===l?c.colours.muted:c.colours.goldLight,size:'No takings entered'===l?13:16,children:l}),n?(0,p.jsx)(r.Muted,{center:!0,children:n}):null]},e);return(0,p.jsxs)(a.default,{style:{gap:12},testID:"sph-screen",children:[(0,p.jsx)(r.Muted,{children:"Tip: spend per head is takings \xf7 Covers. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,p.jsxs)(r.Card,{highlight:c.colours.gold,children:[(0,p.jsx)(r.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==T?(0,p.jsx)(r.T,{size:22,weight:"semibold",colour:c.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,p.jsxs)(r.T,{size:34,weight:"bold",colour:c.colours.goldLight,testID:"sph-avg",children:[x(T)," ",(0,p.jsx)(r.T,{size:16,colour:c.colours.muted,children:"per head"})]}),(0,p.jsx)(r.Muted,{children:f?'Only days with a cash up are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has card and cash totals.'})]}),(0,p.jsxs)(r.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(r.Chip,{testID:"sph-day",label:"By day",selected:'day'===j,onPress:()=>w('day')}),(0,p.jsx)(r.Chip,{testID:"sph-week",label:"By week",selected:'week'===j,onPress:()=>w('week')})]}),'day'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by day"}),(0,p.jsx)(b,{testID:"sph-trend-day",label:"Spend per head trend by day",points:v.map(e=>({label:y(e.date),value:e.sph}))}),[...v].reverse().map(e=>S(e.date,y(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':x(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${x(e.foodPh)}, drink ${x(e.drinkPh)} per head`:void 0))]}):null,'week'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,p.jsx)(b,{testID:"sph-trend-week",label:"Spend per head trend by week",points:$.map(e=>({label:`w/c ${y(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...$].reverse().map(e=>S(e.weekStart,`w/c ${y(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':x(e.sph)))]}):null,(0,p.jsx)(r.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=_r(_d[1]),a=e(_r(_d[2])),n=_r(_d[3]),i=e(n),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]);const x=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function b({points:e,testID:l,label:o}){const[d,h]=(0,s.useState)(320),[u,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,l]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,u)),w=Math.max(0,j-b),f=e.slice(w,j),k=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)),T=e=>38+e*(k-76)/Math.max(1,f.length-1),S=e=>140-e/$*106,L=[];let D=[];f.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} ${x(e.value)}`).join(', ');return(0,p.jsxs)(a.default,{testID:l,onLayout:e=>h(e.nativeEvent.layout.width),style:{gap:8},children:[(0,p.jsxs)(a.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,p.jsx)(i.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,p.jsx)(n.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:c.colours.muted,children:x($*e/4)},e))}),(0,p.jsxs)(i.default,{width:k,height:170,children:[[0,1,2,3,4].map(e=>(0,p.jsx)(n.Line,{x1:0,x2:k,y1:S($*e/4),y2:S($*e/4),stroke:c.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,p.jsx)(n.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:c.colours.gold,strokeWidth:2.5},s)),f.map((e,s)=>(0,p.jsx)(t.default.Fragment,{children:null==e.value?(0,p.jsx)(n.Circle,{cx:T(s),cy:140,r:2,fill:"#444"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.Circle,{cx:T(s),cy:S(e.value),r:4,fill:c.colours.goldLight}),(0,p.jsx)(n.Text,{x:T(s),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:c.colours.goldLight,children:x(e.value)})]})},w+s))]})]}),(0,p.jsx)(a.default,{style:{flexDirection:'row',gap:12},children:f.map((e,s)=>(0,p.jsxs)(a.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':x(e.value)}`,children:[(0,p.jsx)(r.T,{center:!0,size:12,colour:c.colours.muted,children:e.label}),(0,p.jsx)(r.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?c.colours.muted:c.colours.goldLight,children:null==e.value?'No takings entered':x(e.value)})]},w+s))}),(0,p.jsxs)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(r.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,p.jsx)(r.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))})]})]})}},1504,[17,1465,85,780,777,858,1008,1467,804,1057,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])},1505,[17,85,1348,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])},1506,[17,776,1057,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:a,role:I,today:x,signedIn:j}=(0,b.useCtx)(),[D,P]=(0,t.useState)('today'),R=(0,r.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),W=(0,c.useOwner)(e=>(0,c.liveAttendance)(e.attendance)),C=(0,b.useHourly)(),S=(0,$.useReviews)(e=>e.reviews),N=(0,u.canSeeTakingsStats)(I,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,v.ensureReviewSync)(e,'manage')},[e]);const M=(0,u.rangeFor)(x,D),L=(0,u.previousRange)(x,D),G=(0,t.useMemo)(()=>R.filter(s=>s.restaurantId===e),[R,e]),_=(0,u.coversInRange)(G,M),O=(0,u.coversInRange)(G,L),B=(0,u.noShowRate)(G,M,e),F=(0,u.noShowRate)(G,L,e),A=(0,u.cancelRate)(G,M,e),H=(0,u.cancelRate)(G,L,e),V='today'===D?(0,h.laterTodayCovers)(G,x):0,z=(0,u.takingsInRange)(T,e,M),U=(0,u.takingsInRange)(T,e,L),E=(0,s.coverOverridesFor)(e),Y=(0,u.spendPerHeadInRange)(T,G,e,M,E),q=(0,u.spendPerHeadInRange)(T,G,e,L,E),J=(0,u.tipsInRange)(T,e,M),K=(0,u.tipsInRange)(T,e,L),Q=(0,t.useMemo)(()=>W.filter(e=>'confirmed'===(0,c.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,b.paidMins)(e,a).paid,ratePence:C[e.staffId]??0})),[W,C,a]),X=(0,t.useMemo)(()=>W.filter(e=>'awaiting'===(0,c.attStatus)(e)).map(e=>e.date),[W]),Z=(0,u.labourVsTakings)(Q,X,T,e,M),ee=(0,u.labourVsTakings)(Q,X,T,e,L),se=(0,u.tipsVsTakings)(T,e,M),te=(0,u.firstVisitDate)(G,e),ae=(0,u.repeatGuestPct)(G,M,e),ne=(0,u.repeatGuestPct)(G,L,e),ie=(0,u.reviewAverage)(S.filter(s=>s.restaurantId===e),M),oe='today'===D?'today':'week'===D?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(o.T,{weight:"semibold",size:y.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(o.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)(o.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(o.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:D===e.id,onPress:()=>P(e.id)},e.id))}),(0,f.jsx)(w,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${oe}`,value:(0,u.pctLabel)(_.walkInPct),detail:_.empty?void 0:`${_.walkIns} walk-in covers \xb7 ${_.bookings} booked covers \xb7 ${_.total} total`,change:(0,u.changeWords)((0,u.changePct)(_.walkInPct,O.walkInPct),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${oe}`,value:(0,u.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(B.rate,F.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${oe}`,value:(0,u.pctLabel)(A.rate),detail:A.empty?void 0:`${A.count} cancelled out of ${A.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(A.rate,H.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-covers",label:`Covers \xb7 ${oe}`,value:_.empty?null:String(_.total),detail:_.empty?void 0:'today'===D?V>0?`${V} more ${1===V?'cover':'covers'} booked for later today`:'No more bookings for later today':`${_.walkIns} walk-in \xb7 ${_.bookings} booked`,change:(0,u.changeWords)((0,u.changePct)(_.empty?null:_.total,O.empty?null:O.total),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${oe}`,value:(0,u.pctLabel)(ae.rate),detail:ae.empty?void 0:`${ae.count} of ${ae.of} identifiable seated or finished parties had visited before${te?` (visits on record from ${(0,u.ukDay)(te)})`:''}`,change:(0,u.changeWords)((0,u.changePct)(ae.rate,ne.rate),D),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(w,{testID:"insights-reviews",label:`Reviews \xb7 ${oe}`,value:ie.empty?null:`${ie.avg} / 5`,detail:ie.empty?void 0:`Average of ${ie.count} published review${1===ie.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(w,{testID:"insights-tips",label:`Tips (team total) \xb7 ${oe}`,value:(0,u.moneyGbp)((0,u.completeTotal)(J,J.tips)),detail:null==J.tips?void 0:N&&null!=se.pct?`${J.days} cash-up day${1===J.days?'':'s'} \xb7 ${(0,u.pctLabel)(se.pct)} of takings on the ${se.days} day${1===se.days?'':'s'} with takings`:`${J.days} cash-up day${1===J.days?'':'s'}`,change:J.missing||K.missing?null:(0,u.changeWords)((0,u.changePct)(J.tips,K.tips),D),empty:J.missing?(0,u.missingWords)(J.missing,'tips figure',J.missingDates):'No tips entered in this period'}),N?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(w,{testID:"insights-takings",label:`Takings \xb7 ${oe}`,value:(0,u.moneyGbp)(z.gross),detail:null==z.gross?void 0:`Card + cash \u2212 card tips, from ${z.days}${z.missing?` of ${z.days+z.missing}`:''} confirmed cash-up day${z.days+z.missing===1?'':'s'}${z.missing?`. ${(0,u.takingsMissingWords)(z.missingDates)}`:''}`,change:z.missing||U.missing?null:(0,u.changeWords)((0,u.changePct)(z.gross,U.gross),D),empty:z.missing?(0,u.missingWords)(z.missing,'card or cash total',z.missingDates):'No takings entered in this period'}),(0,f.jsx)(w,{testID:"insights-sph",label:`Spend per head \xb7 ${oe}`,value:(0,u.moneyGbp)(Y.sph),detail:null==Y.sph?void 0:`\xa3${Y.gross.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})} takings \xf7 ${Y.covers} seated or finished covers, on ${Y.days} day${1===Y.days?'':'s'} with both${Y.noCovers?`. ${Y.noCovers} day${1===Y.noCovers?'':'s'} with takings and no Covers (a function, say) count${1===Y.noCovers?'s':''} in takings, not here`:''}`,change:(0,u.changeWords)((0,u.changePct)(Y.sph,q.sph),D),empty:Y.noCovers?'Spend per head needs a day with both takings and seated or finished Covers':'No takings entered, so no spend per head'}),(0,f.jsx)(w,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${oe}`,value:(0,u.pctLabel)(Z.pct),detail:null!=Z.pct?`${(0,u.moneyGbp)(Z.labour)} signed-off wages \xf7 ${(0,u.moneyGbp)(Z.gross)} takings, on the ${Z.days} day${1===Z.days?'':'s'} with takings${z.missing?`. ${z.missing} cash up${1===z.missing?'':'s'} with no card or cash total left out`:''}${Z.awaiting?`. ${Z.awaiting} shift${1===Z.awaiting?'':'s'} on those days still need${1===Z.awaiting?'s':''} signing off, not counted yet`:''}`:void 0,change:(0,u.changeWords)((0,u.changePct)(Z.pct,ee.pct),D),empty:j||Object.keys(C).length?null==Z.gross?'Not enough data: no cash up in this period has a card or cash total':'Not enough data: no signed-off hours with a pay rate on the days with takings':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(o.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-not-shown",children:(0,f.jsx)(o.Muted,{center:!0,children:u.NOT_SHOWN_YET})})]})};var e,s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=(e=a)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),y=_r(d[10]),v=_r(d[11]),$=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function w({testID:e,label:s,value:t,detail:a,change:r,empty:l}){const c=!!r&&r.startsWith('Up'),h=!!r&&r.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.Muted,{center:!0,children:s}),null==t?(0,f.jsx)(o.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:l}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.T,{testID:`${e}-value`,weight:"semibold",size:y.font.hero,colour:y.colours.gold,center:!0,children:t}),a?(0,f.jsx)(o.Muted,{center:!0,children:a}):null,r?(0,f.jsx)(o.T,{testID:`${e}-change`,center:!0,colour:c?y.colours.goldLight:h?y.colours.muted:y.colours.text,children:r}):null]})]})})}},1507,[1465,17,85,777,858,1008,876,1055,1466,899,804,1241,1242,1057,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]})}},1508,[805,1418,812,822,843,1509,1437,1487,1227,841,1262,899,1510,1512,1438,17,1098,1495,13,385,85,864,1280,777,858,876,851,866,1105,1251,863,804,1183,1057,1139,869,1456,853,1026,1154,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)},1509,[843,17,85,777,845,851,1153,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)}}})]})}},1510,[899,17,264,219,85,1280,777,1259,1262,804,1511,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},1511,[17,219,85,777,1259,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'})})}},1512,[805,1418,17,85,777,851,1259,1260,1261,899,1262,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}),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'}]},1513,[812,891,779,869,1216,17,378,219,385,278,85,831,777,1098,858,876,1514,1518,804,1057,1071,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]}})})},1514,[1515,1517,1516]); -__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)}},1515,[843,1516]); -__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'}},1516,[]); -__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}},1517,[1515,1217]); -__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},1518,[869,824,831,834]); -__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})}},1519,[17,1211,1156,1212,1224,1057,1174,847,856,993,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'},1520,[17,85,777,899,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=v,_e.SmsBubble=C,_e.AlertSettings=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=(0,p.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,p.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,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,k.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,k.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>p.useAlerts.getState().setPrefs({muted:!e})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,y.chime)('bright')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,y.lowChime)(.6)})]}),(0,k.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,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,k.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),p.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindChip,{kind:e,size:30}),(0,k.jsx)(c.default,{style:{flex:1},children:(0,k.jsx)(h.Toggle,{label:p.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>p.useAlerts.getState().setType(e,s)})})]},e))]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,k.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,k.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,k.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${p.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,p.sendTestAlert)(s,e)},e))})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,k.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,k.jsx)(h.Muted,{children:r}),(0,k.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>p.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,k.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,p.requestSystemPermission)()),p.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,p.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,k.jsx)(h.Muted,{children:(0,p.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,k.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,k.jsx)(w.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindIcon,{kind:"email"}),(0,k.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,k.jsx)(h.Badge,{kind:"neutral",label:p.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,k.jsx)(h.Muted,{children:p.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${p.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,k.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,T.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,j.templatesFor)(r),[r]),p=(0,x.useAssistant)(e=>e.enabled)&&b.ASSISTANT_UI,[y,w]=(0,n.useState)('booking'),[A,M]=(0,n.useState)('sms'),B=u[y],I=s=>m.useStore.getState().setTemplate(e,y,s),R=Object.fromEntries(j.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===y?(0,j.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,j.bookingVars)({...S,date:o},s),N=(0,j.toGsm)((0,j.fill)(B.sms,L.sms)),_=(0,j.fill)(B.subject,L.email),D=(0,j.emailHtml)((0,j.fillEmailText)(B.body,L.email),{venue:s.name,preheader:_}),O=!!r?.[y],V=s.settings;return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:j.PREVIEW_BANNER}),(0,k.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,k.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(j.DEFAULT_TEMPLATES).map(e=>(0,k.jsx)(h.Chip,{label:j.TEMPLATE_LABEL[e].title,selected:y===e,onPress:()=>w(e)},e))}),(0,k.jsx)(h.Muted,{children:j.TEMPLATE_LABEL[y].when}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,k.jsxs)(h.Muted,{children:[(0,j.smsParts)(N).chars," characters"]})]}),(0,k.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:B.sms,onChangeText:e=>I({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,j.smsParts)(N).chars>300?(0,k.jsx)(h.T,{size:13,colour:f.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,k.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:B.subject,onChangeText:e=>I({subject:e}),style:h.styles.input}),(0,k.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,k.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:B.body,onChangeText:e=>I({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,k.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[p?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>I(P(B))}):null,O?(0,k.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,y,null)}):null]}),p?(0,k.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,k.jsxs)(h.Muted,{children:["Placeholders: ",j.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:"Text",selected:'sms'===A,onPress:()=>M('sms')}),(0,k.jsx)(h.Chip,{label:"Email",selected:'email'===A,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,k.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,k.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===y?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===A?(0,k.jsx)(C,{text:N,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),_]}),(0,k.jsx)(v,{html:D})]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,k.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,k.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:V.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,k.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!V.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,k.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,T.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),b=t.filter(e=>'all'===l||e.channel===l);return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:f.colours.gold,borderRadius:12,padding:12},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:f.colours.gold,children:(0,j.isLive)()?'Live: messages are sent through your text and email service.':j.PREVIEW_BANNER}),(0,j.isLive)()?null:(0,k.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,k.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,k.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),b.length?null:(0,k.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),b.map(e=>(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,k.jsxs)(h.T,{weight:"semibold",children:[A[e.kind]," \xb7 ",e.ref]})]}),(0,k.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,k.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,k.jsx)(h.T,{size:13,colour:'sent'===e.status?f.colours.ok:'failed'===e.status?f.colours.red:f.colours.amber,children:(0,j.statusLabel)(e)})]}),'sms'===e.channel?(0,k.jsx)(C,{text:e.body}):u===e.id?(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),e.subject]}),(0,k.jsx)(v,{html:e.html??'',height:560})]}):(0,k.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,k.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]),k=_r(d[18]);function v({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 C({text:e,to:t}){const l=(0,j.smsParts)(e);return(0,k.jsxs)(c.default,{style:{gap:4},children:[t?(0,k.jsxs)(h.Muted,{children:["To ",t]}):null,(0,k.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,k.jsx)(h.T,{size:15,children:e})}),(0,k.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const S={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 P(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 A={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1521,[813,812,822,17,219,385,85,777,1229,858,1518,1213,848,1231,1018,804,1027,1057,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:n,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,b=n.settings,x=(0,r.bookingRulesOf)(n),f=(0,o.usePlan)(g),j=(f?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...b.bookingRules??{},...x,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(n),M=(0,d.depositOf)(b),R=b.reservables??(0,i.reservablesOf)(n),O=(0,r.accessGuideOf)(n),[I,A]=(0,t.useState)(null),D=(e,t)=>T({largeGroups:x.largeGroups.map((n,s)=>s===e?{...n,...t}:n)});return(0,y.jsxs)(s.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."}),I?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:I}):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:b.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)(n)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(n)} 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."}),x.largeGroups.map((e,t)=>(0,y.jsxs)(s.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=>D(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>D(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=>D(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:x.largeGroups.filter((e,n)=>n!==t)})}):null]},t)),x.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=x.largeGroups[x.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...x.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:j.map(e=>{const t=x.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(x.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:x.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)(x,n.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(x.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(x.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:x.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!==b.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:x.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),x.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,x.onlineTableMins.map((e,t)=>(0,y.jsxs)(a.Muted,{center:!0,testID:`rules-table-min-${t}`,children:[(0,r.onlineTableMinLine)(e),". Staff can still book them for fewer."]},t)),(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:b.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:M.on&&M.perPersonPence>0?`${w(M.perPersonPence)} per adult for ${M.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),R.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:x.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:x.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:x.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:x.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:x.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:x.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}),A('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:n}=(0,k.useCtx)(6e4),o=T(n),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,b.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,f.isSupabaseConfigured)())return;let e=!0;try{(0,x.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:n})=>{e&&!n&&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)(s.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,f.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,x.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:j.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),n=_r(_d[1]),s=(e=n)&&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]),b=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),j=_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(b.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()},1522,[17,85,777,858,998,1079,1055,841,1105,1251,889,876,920,899,928,971,804,1057,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)})]})]})}},1523,[17,385,85,777,876,1000,851,1001,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]})}},1524,[17,219,385,85,409,777,804,1376,857,1380,863,899,1381,1057,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})},1525,[820,896,1454,17,219,85,777,816,876,895,1000,897,899,1526,804,880,1162,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'}},1526,[]); -__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])},1527,[17,85,777,804,1433,1509,1057,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=w,_e.HelpPage=function({go:e}){const[s,o]=(0,a.useState)(''),[r,h]=(0,a.useState)(null),[p,x]=(0,a.useState)(null),w=(0,a.useMemo)(()=>[...c.HELP,...m],[]),j=(0,a.useMemo)(()=>s.trim()?(0,u.searchHelp)(w,s,10).map(e=>e.a):w.filter(e=>!r||e.topic===r),[s,r,w]);return(0,f.jsxs)(i.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(i.default,{style:[l.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(l.T,{colour:y.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:o,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:y.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(n.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>o('')}):null]}),s?(0,f.jsx)(l.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)(l.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(l.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,n)=>(0,f.jsx)(b,{a:t,go:e,open:p===t.id||!!s&&0===n&&null===p,onToggle:()=>x(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(l.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",colour:y.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(l.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(l.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=function({go:e}){const{rid:t,today:s}=(0,x.useCtx)(6e4),n={rid:t,today:s,go:(t,s)=>e(t,s??null)},[o,r]=(0,a.useState)(''),[h,u]=(0,a.useState)(null),[m,b]=(0,a.useState)(null),C=async()=>{const e=o.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,n);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...j(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(i.default,{testID:"ask-assistant",children:(0,f.jsxs)(l.Card,{highlight:y.colours.gold,children:[(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(i.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(l.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:o,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:C,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(l.Button,{label:"Ask",testID:"assistant-ask",disabled:!o.trim(),onPress:C,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(l.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)(l.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(k,{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,n,!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,m?(0,f.jsxs)(i.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(l.Banner,{kind:'done'===m.kind?'success':'error'===m.kind?'warn':'demo'===m.kind?'demo':'info',title:m.text}),m.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>w(s,e)}):null]},t)})]}):null,(0,f.jsx)(l.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),o=e(_r(d[4])),i=e(_r(d[5])),l=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),y=_r(d[12]),x=_r(d[13]),f=_r(d[14]);const m=[{id:'ai-assistant-pairing',kind:'faq',topic:'Accounts',title:'Can I connect my own AI assistant?',keywords:['assistant','ai','pair','pairing','grok','bot','unpair','approve','draft','log'],body:'AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. In the connected assistant, it can answer questions about your venue and give advice from the venue data it is allowed to look up. It can draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged, including look-ups. Open More \u203a Account \u203a Assistants, as an owner, on Full Restaurant Pro, SuperPro or the early adopter offer. It is not included with Customer & Takeaway App, and there is no AI assistant on the Display app.',showMe:{tab:'more',page:'assistants',target:{testID:'assistants-page'},hint:'Pair, switch off or unpair an assistant here. Owners only.'}},{id:'customer-support',kind:'faq',topic:'Accounts',title:'How do I contact CoverCharge support?',keywords:['support','customer support','help','email','picture','photo','screenshot','contact','covercharge'],body:'Customer support is at the very bottom of Home, and at the bottom of More, as an owner. Write a message, attach one picture if you like (a photo or a screenshot), and tap Send to CoverCharge. It is sent with your venue name, your name and email, and the app version. You will see \u201cSent. We\u2019ll reply by email.\u201d if it went through, or an error with a way to try again. There is no Customer support on the Display, Staff, Front of House or Head Chef apps.',showMe:{tab:'more',page:'support',target:{testID:'customer-support'},hint:'Write a message, attach a picture if you like, and send it to CoverCharge. Owners only.'}},{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:'In the Managers app go to More \u203a Run the day \u203a Display settings 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. There is no wipe or unpair button on the Display itself. To switch a Display off, go to Settings \u203a Displays and choose Switch off.',showMe:{tab:'more',page:'displaysettings',target:{testID:'wipe-setting'},hint:'Sign out and wipe is in Display settings, in the Managers app only.'}}];function w(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 b({a:e,go:t,open:s,onToggle:n}){return(0,f.jsx)(i.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(o.default,{accessibilityRole:"button",onPress:n,children:(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(i.default,{style:{flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(l.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(l.T,{colour:y.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(i.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(l.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>w(e,t)})}):null]})})}function j(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function k({p:e,today:t,onChange:n,onConfirm:a,onCancel:o}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>n({...e.params,[t]:s}),x=e.action,m=e.params,w=x.params.every(e=>!e.required||void 0!==m[e.name]&&''!==m[e.name]);return(0,f.jsxs)(i.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?y.colours.red:y.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':y.colours.okBg},children:[(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[x.risk]}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:x.title})]}),x.form&&'add_walkin'===x.id?(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Covers",value:void 0===m.covers?'':String(m.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Table (optional)",value:void 0===m.table?'':String(m.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,x.form&&'add_rota_shift'===x.id?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{size:12,children:"Who"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(l.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:m.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1.3},children:(0,f.jsx)(l.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(m.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Start (24h)",value:String(m.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"End (24h)",value:String(m.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(l.T,{children:w?x.preview(m,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(l.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(l.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(l.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!w,onPress:a,style:{flex:1}}),(0,f.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:o,style:{flex:1}})]})]})}},1528,[812,1033,779,17,385,85,777,876,1479,1529,1530,1531,804,1057,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.','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:'guest-change-link',kind:'faq',topic:'Bookings',title:'Can guests change or cancel their own booking?',keywords:['change','cancel','link','email','guest','move','booking'],body:'Yes. The confirmation email has a "Change or cancel your booking" link for that one booking, with "Or call us on (your number) and quote your booking details." underneath. Guests can change the date, time or party size within your online booking rules, or cancel after confirming. Bookings with a deposit say "please call us" instead. Takeaway orders can\u2019t be changed or cancelled by the guest, and their email has no link. You see every change on the Display and in Managers, marked as changed by the guest. The link stops working at the booking time.'},{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:'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 takings \xf7 Covers, by day and by week. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). 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.'},{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.'}],o=t=>a.find(a=>a.id===t)},1529,[]); -__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}},1530,[]); -__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}},1531,[1532,1100,843,1533,1534,876,858,998,1479,1529,1530,1536,1535,1538,1539,996,997]); -__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))}}]},1532,[1064,1063,1023]); -__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.`)}}]},1533,[896,1100,820,843,1121,1098,1115,922,858,816,998,895,897,1010,876,1067,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]),n=_r(_d[3]),r=_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)=>r.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(),n=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(n){const e=Number(/\d/.test(n[1])?n[1]:n[2]),a=L.indexOf(/\d/.test(n[1])?n[2]:n[1]);let r=Number(t.slice(0,4));return`${r}-${A(a+1)}-${A(e)}`e.active)){const n=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),r=Math.min(...n.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));r<1/0&&a.push({s:e,at:r})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>r.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(),n=U(e);if(!n.length)return;const r=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(r)return n.find(e=>e.number===Number(r[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=n.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===n.length?n[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const r=a.useStore.getState(),i=r.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=n.useFloor.getState(),c=d.plans[e]??(0,n.seedPlan)(e),h=r.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,r.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 n=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return n?`Seat ${Y(a)}, at table ${n}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const r=z(a.rid,e.who);if(!r)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,r.partySize);return i?(await t.repo.waitlist.setStatus(r.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,r.partySize,i,`From waitlist #${r.number}`),(0,n.tablesOf)(i).forEach(e=>n.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${r.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=r.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),n=j(String(t??''),e.today);return n?a.find(e=>e.date===n):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(),n=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(n){const e=j(n[1],t),a=j(n[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!n||e.kind===n)),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 ne(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),n=new Date(a+'T00:00:00').getTime(),r=n+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=n&&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>=n&&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)()),n=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),r=(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=>r.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),n):[];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 n;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(n?.s??0)&&(n={m:t,s:e})}return n?.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 n=z(a.rid,e.who);return n?(await t.repo.waitlist.setStatus(n.id,'removed'),`Done: number ${n.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,r)=>{const i=z(r.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===r.rid);return n.useFloor.getState().logSms(r.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?r.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(r.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),n=E(e.with);return n&&n.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(n.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),n=E(e.with);return a&&t.whoId?n&&n.id!==t.whoId?(r.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:n.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(n.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)())),n=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:n&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(n[1])?n[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=r.useOwner.getState().shifts.find(e=>e.id===t.shiftId),n=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${n}\u2019s swap with ${i}`:t.toId?`${i} covering ${n}`:`${n}\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 ${n}\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=r.useOwner.getState(),n=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)}${n?` (${M[n.day]} ${R(n.start)}\u2013${R(n.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 n=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: ${n.n} checks, ${n.bad} out of range${n.bad?`, ${n.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:n}=ne(t.today,t),r=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(r)return`This week is already signed off by ${r.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${n.entries} checks, ${n.outOfRange} out of range, ${n.actions} with an action, diary signed ${n.daysSigned} of 7 days.`;return n.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:n}=ne(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':n.actions!0),note:'Signed by voice: yes to all.',summary:n}),'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),n=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${n}; 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)),n='Near miss'===a.category,r=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(r)}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??'')||(n?'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:n,rem:r}=se(t,e.task);return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?`${_(n.text)} is already ticked today.`:`Tick off today\u2019s task ${_(n.text)}?`:r?`Mark the reminder ${_(r.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:n,rem:r}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,n.id,a,i),`Done: ${_(n.text)} ticked.`):r?(c.useReminders.getState().markDone({rid:t.rid,reminderId:r.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),r=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=n?.sections.find(e=>r.includes(e.toLowerCase())||r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=String(e.section??n?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${r} 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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(r)||r<=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??n?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:r,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 n=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 n?{dish:n[1],field:'description',value:n[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 n=de(t.rid,e.dish),r=String(e.value??'').trim();return n?r.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(n.id,'name'===e.field?{name:r}:{description:r}),'name'===e.field?`Done: renamed to ${r}.`:`Done: description of ${n.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 n=(0,$.findCard)(t.rid,a.dish);return n?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${n.dish}\u2019s recipe card?${n.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)),n=a&&(0,$.findCard)(t.rid,a.dish);return a&&n?(await(0,y.recipeCards)().update(n.id,{ingredients:[...n.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 ${n.dish}.${n.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,n=String(e.step??'').trim();return!a||n.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,n]},{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],n=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),r=/\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:r,reason:n?.[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 n=e.action??'in',r=(0,g.managerClockAction)(n,{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 r.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[n]} at ${D()}.${r.warn?' '+r.warn:''}`:'Nothing changed: '+r.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 n=h.useCashUp.getState(),r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,r?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(n.tips.filter(e=>e.rid===t.rid),n.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: 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 n='yesterday'===e.day?(0,l.ymdOf)(a):e.day,r=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!n||e.date===n)).sort((e,t)=>t.date.localeCompare(e.date)),i=r[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: takings ${fe((0,p.tillTakingsOf)(i.vals))} (card + cash \u2212 card tips), tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:n?`There\u2019s no cash-up for ${(0,$.niceDay)(n)}.`:'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 r='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,n.tablesOf)(a).forEach(e=>n.useFloor.getState().setLive(t.rid,e,{note:r||void 0})),r?`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 n=(0,$.appNow)();return r.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(n)} ${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',n=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),r=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:n?.[1]?.trim(),time:r?(0,$.hm)(r[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??''),n=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(n)}, ${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(),n=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(n))return'Nothing changed: I need the wording and a time like 21:00.';const r=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:r,time:n,audience:e.audience??'all'}),'Done: reminder added.'}}]},1534,[820,858,816,998,876,1003,1014,1015,927,926,1008,839,1034,1035,1036,1004,1067,867,1076,995,854,1535,1533]); -__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.'}}]},1535,[820,891,1100,843,1140,1262,858,816,998,1003,910,846,845,1076,1077,995,1004,851,1536,1537]); -__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)}))},1536,[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)}))},1537,[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)])},1538,[816,876,910,851,1535,1017,1071]); -__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))'},1539,[]); -__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,u.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:u.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:u.VOICE_ROLE_LABEL[s],value:(0,u.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,h.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:p}=(0,f.useCtx)(6e4),u=(0,r.useDrafts)(e=>e.drafts),h=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=u.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),D='owner'===p||'manager'===p,C=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:r.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&&D?(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'})}),C(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${C(e).name} ordering`,onPress:()=>{t.default.openURL(C(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:"Drafts saved earlier (bookings, supplier shopping lists, offers, events, specials, messages and payments) wait 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."}),D?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:()=>{h(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,p.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,p.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. 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]),r=_r(_d[6]),l=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),h=_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'}}},1540,[17,362,85,777,804,1475,1536,1487,1537,1541,1216,1542,1057,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return s}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(f(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(f(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),s=(e,n,t)=>!1!==e[n]?.[t],f=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1541,[824,831,834]); -__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])},1542,[17,85,777,804,1543,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.'},1543,[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}},1544,[17,779,85,777,845,1259,1545,1546,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'},1545,[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()})},1546,[899,1545,1262]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:l,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,o.useCashUp)(e=>e.cashUps),k=(0,o.useCashSettings)(e),w=(0,d.useNightlyPrefs)(s=>s.email[e]??!1),T=(0,d.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(s=>s.rid===e&&s.on).map(e=>e.name),[N,U]=(0,s.useState)((0,u.addDaysYmd)(v,-1)),P=(0,u.cashFieldsForRecord)(k.cashFields,(0,u.cashUpRecordFor)(e,l.settings.cashUpRecord)),R=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:P,soldOut:C}),_='anchorage'!==e&&w,D=[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:D.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:()=>U(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:R.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(R.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(R.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(R.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:R.takings}),(0,j.jsx)(x,{label:"Tips",value:R.tips}),(0,j.jsx)(x,{label:"Takings last week",value:R.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:R.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:R.soldOut.length?R.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),R.cashUp.length?R.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:_,onChange:s=>T(e,s)}):null]})};var e,s=_r(_d[0]),l=_r(_d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),d=_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:s})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${s}`,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:s})]})},1547,[17,85,777,858,1008,1548,891,839,1549,1020,804,1057,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}))},1548,[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.tillTakingsOf)(k.vals):null,N=(0,l.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:s(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(y),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(O?(0,t.tillTakingsOf)(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]),l=r(d[2]);const s=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?s(t):String(t);function u(t,l,u){const c=[];for(const f of l){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const l=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==l?'Not entered':s(l)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!l.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const l=(0,n.expectedCashInDrawer)(t);null!=l&&c.push({label:'Expected cash in the drawer',value:s(l)})}return c}},1549,[839,1009,1467]); -__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.SupportChatPage=function(){const{r:e,me:f,meId:x}=(0,h.useCtx)(6e4),[j,v]=(0,s.useState)(''),[C,I]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[R,D]=(0,s.useState)('idle'),[L,P]=(0,s.useState)(''),[k,B]=(0,s.useState)(''),[_,T]=(0,s.useState)('');(0,s.useEffect)(()=>{(0,p.signedInEmail)().then(B)},[]);const E=async e=>{T('');try{const t=await(0,c.capturePlatingPhoto)(e);t&&(I(t),D(e=>'sent'===e?'idle':e))}catch(e){T(e instanceof Error?e.message:'Could not add that picture.')}},H=async()=>{const t=j.trim();if(!t||w)return;S(!0),P(''),D('idle');const s=await(0,p.writeSupportRequest)({venueName:e.name,body:t,fromName:f.replace(' (example)',''),fromEmail:k,staffRef:x||'',appVersion:u.APP_VERSION,photoDataUrl:C?.dataUrl??null});if(S(!1),s.ok)return v(''),I(null),D('sent'),void P(b);D('error'),P(s.message)};return(0,y.jsxs)(l.default,{testID:"customer-support",style:{gap:12,alignItems:'center',width:'100%',paddingBottom:8},children:[(0,y.jsx)(o.T,{center:!0,weight:"bold",colour:n.colours.gold,accessibilityRole:"header",children:"Customer support"}),(0,y.jsx)(o.Muted,{center:!0,children:"Send a message to CoverCharge. You can attach one picture, such as a photo or a screenshot. We'll reply by email."}),'sent'===R?(0,y.jsx)(l.default,{testID:"support-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:b,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"success",title:b})}):null,'error'===R?(0,y.jsx)(l.default,{testID:"support-error",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:L,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"danger",title:L})}):null,(0,y.jsx)(t.TextInput,{testID:"support-message",accessibilityLabel:"Your message to CoverCharge",value:j,onChangeText:e=>{v(e),'sent'===R&&D('idle')},placeholder:"Write your message",placeholderTextColor:n.colours.muted,multiline:!0,style:{width:'100%',minHeight:120,borderWidth:1,borderColor:n.colours.border,borderRadius:12,padding:12,color:n.colours.text,textAlign:'center'}}),C?(0,y.jsxs)(l.default,{testID:"support-photo-preview",style:{alignItems:'center',width:'100%',gap:8},children:[(0,y.jsx)(r.default,{source:{uri:C.dataUrl},style:{width:240,height:180,borderRadius:12,backgroundColor:n.colours.surface2},accessibilityLabel:"Attached picture preview"}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Remove picture",accessibilityLabel:"Remove the attached picture",testID:"support-photo-remove",onPress:()=>I(null),style:{minHeight:48}})]}):(0,y.jsxs)(l.default,{style:{width:'100%',gap:8,alignItems:'center'},children:[(0,y.jsx)(o.Button,{kind:"secondary",label:"Take a photo",accessibilityLabel:"Take a photo to attach",testID:"support-photo-camera",onPress:()=>{E('camera')},style:{minHeight:48,width:'100%'}}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a picture or screenshot from your gallery",testID:"support-photo-gallery",onPress:()=>{E('library')},style:{minHeight:48,width:'100%'}})]}),_?(0,y.jsx)(o.Muted,{center:!0,testID:"support-photo-error",children:_}):null,(0,y.jsx)(o.Button,{testID:"support-send",label:"Send to CoverCharge",accessibilityLabel:"Send to CoverCharge",disabled:!j.trim()||w,onPress:()=>{H()},style:{minHeight:56,width:'100%'}}),w?(0,y.jsx)(l.default,{accessibilityLiveRegion:"polite",style:{width:'100%'},children:(0,y.jsx)(o.Muted,{center:!0,testID:"support-sending",children:"Sending\u2026"})}):null]})};var t=_r(d[0]),s=_r(d[1]),r=e(_r(d[2])),l=e(_r(d[3])),o=_r(d[4]),n=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),y=_r(d[10]);const b="Sent. We'll reply by email."},1550,[812,17,319,85,777,804,1082,978,1551,1057,8]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPPORT_BUCKET",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SUPPORT_SEND_FAILED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SUPPORT_SIGN_IN",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SUPPORT_NO_EMAIL",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SUPPORT_PHOTO_FAILED",{enumerable:!0,get:function(){return l}}),e.writeSupportMessage=async function(o){if(!t.RELEASE.supportSync)return{ok:!1,message:n.SUPPORT_NOT_SENT};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:n.SUPPORT_NOT_SENT};const c=u.useSync.getState().venueId;if(!c)return{ok:!1,message:`${n.SUPPORT_NOT_SENT} Sign in and try again.`};try{const t=(0,i.getSupabase)(),{error:s}=await t.from('support_messages').insert({venue_id:c,body:o.text,from_name:o.from,staff_ref:o.staffRef||null});return s?{ok:!1,message:n.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:n.SUPPORT_NOT_SENT}}},e.writeSupportRequest=async function(t){if('undefined'!=typeof globalThis&&globalThis.__CC_SUPPORT_FAKE_SEND)return{ok:!0,id:'preview-test',emailed:!0};const n=t.body.trim().slice(0,4e3),S=t.fromName.trim().slice(0,80),y=t.fromEmail.trim().slice(0,254),P=t.venueName.trim().slice(0,120);if(!n||!S||!P)return{ok:!1,message:f};if(!y||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y))return{ok:!1,message:m};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:p};const b=u.useSync.getState().venueId;if(!b)return{ok:!1,message:p};const T=globalThis.crypto?.randomUUID?.()??`00000000-0000-4000-8000-${Date.now().toString(16).padStart(12,'0')}`,O=(0,i.getSupabase)();let h=null;if(t.photoDataUrl)try{const n=_(t.photoDataUrl);h=`${b}/${T}.jpg`;const{error:o}=await O.storage.from(c).upload(h,n,{contentType:'image/jpeg',upsert:!1});if(o)return{ok:!1,message:l}}catch{return{ok:!1,message:l}}const E={id:T,venue_id:b,venue_name:P,body:n,from_name:S,from_email:y,staff_ref:t.staffRef||null,app_version:(t.appVersion||o.APP_VERSION).slice(0,40),photo_path:h},{error:N}=await O.from('support_requests').insert(E);if(N)return{ok:!1,message:f};let U=!1;try{const t=await O.functions.invoke('send-support-email',{body:{request_id:T}}),n=t.data;U=!t.error&&!!n?.sent}catch{U=!1}return{ok:!0,id:T,emailed:U}},e.signedInEmail=async function(){if(!(0,s.isSupabaseConfigured)())return'';try{const{data:t}=await(0,i.getSupabase)().auth.getUser();return(t.user?.email??'').trim()}catch{return''}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),i=r(d[4]),u=r(d[5]);const c='support-photos',f='Could not send. Check your connection and try again.',p='Could not send. Sign in and try again.',m='Your sign-in has no email. Sign in again and try again.',l='Could not attach the picture. Try a smaller photo, or send without a picture.';function _(t){const n=/^data:([^;]+);base64,(.+)$/.exec(t);if(!n)throw new Error('bad picture');const o=atob(n[2]),s=new Uint8Array(o.length);for(let t=0;t{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{}}},1552,[17,264,219,85,777,812,804,899,1428,1187,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+'},1553,[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 ']]},1555,[]); -__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:te,height:se}=(0,a.default)(),[oe,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(!1),[le,ae]=(0,t.useState)(!1),[de,ce]=(0,t.useState)(''),[ue,ge]=(0,t.useState)(!1),[he,pe]=(0,t.useState)(!1),[be,fe]=(0,t.useState)(!1),[me,xe]=(0,t.useState)(!1),ke=(0,t.useRef)(null),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(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,M.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const Ce=(0,K.useTakingsAllowed)(s),ve=(0,t.useCallback)(e=>{const t=(0,A.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),De=(0,t.useMemo)(()=>(0,V.buttonsFor)({takings:Ce,pageOk:ve}),[Ce,ve]),Ie=oe?(0,V.tabsFor)(oe.btn,{takings:Ce,pageOk:ve}):[],Se=(0,t.useCallback)((e,t)=>{const s=(0,V.tabsFor)(e,{takings:Ce,pageOk:ve});s.length&&(ie(!1),ae(!1),ce(''),ne({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[Ce,ve]),Te=De.find(e=>'settings'===e.id),Re=(0,t.useCallback)(e=>{const t=De.find(t=>t.pages.some(t=>t.id===e));t?Se(t,e):Te&&ve(e)&&(ie(!1),ae(!1),ce(''),ne({btn:Te,tab:'@desk-settings',page:e}))},[De,Se,Te,ve]),Oe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Re(t);else{if('bookings'===e){const e=De.find(e=>'bookings'===e.id);return void(e&&Se(e,'@bookings'))}if('chat'===e){const e=De.find(e=>'chat'===e.id);return void(e&&Se(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Te&&Se(Te):ne(t=>({btn:t?.btn??De[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else ne(null)},[De,Se,Re,Te]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Oe}),()=>T.useVoiceNav.setState({go:null})),[Oe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Oe('bookings'):'chat'===e?Oe('chat'):Oe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Pe=!oe||De.some(e=>e.id===oe.btn.id)&&Ie.some(e=>e.id===oe.tab)&&(!oe.page||ve(oe.page));(0,t.useEffect)(()=>{if(!Pe){const e=setTimeout(()=>ne(null),0);return()=>clearTimeout(e)}},[Pe]);const Le=oe?.page?(0,A.pageFor)(oe.page):void 0,We=oe?(0,_.deskCopy)(Le?.title??oe.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${We} \xb7 The Anchorage \xb7 CoverCharge for desktop`),we.current?.scrollTo?.({y:0,animated:!1}),oe){const e=setTimeout(()=>Y(je.current),80);return()=>clearTimeout(e)}},[We,oe?.tab,oe?.page]),(0,t.useEffect)(()=>{if(le){const e=setTimeout(()=>ke.current?.focus?.(),100);return()=>clearTimeout(e)}},[le]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=q(e.target),s=(0,_.commandKey)(e,t);if('escape'===s){if(le||ue||he||be)return e.preventDefault(),ae(!1),ge(!1),pe(!1),void fe(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return re?(e.preventDefault(),void ie(!1)):void(oe&&(e.preventDefault(),ne(null)))}if(le||ue||he||be||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),ie(!1),void ae(!0);if('help'===s)return e.preventDefault(),void ge(!0);if('filter'===s&&ye.current&&oe)return e.preventDefault(),void ye.current?.focus?.();const o=t?null:(0,_.shortcutIndex)(e);null!=o&&De[o]&&(e.preventDefault(),Se(De[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[le,ue,he,be,re,oe,De,Se]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Oe,globalThis.__deskOpen=(e,t)=>{const s=De.find(t=>t.id===e);s&&Se(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Oe,De,Se]);const Be=(0,t.useMemo)(()=>{const e=de.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De.flatMap(e=>(0,V.tabsFor)(e,{takings:Ce,pageOk:ve}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Se(e,t.id)}))),o=new Set(De.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...A.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,_.deskCopy)(e.title),sub:(0,_.deskCopy)(e.sub??''),run:()=>Re(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[de,De,s,Ce,ve,Se,Re]),He=(0,N.ddmmyyyy)(o),Me=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),Ee=b?(0,B.authorityRole)(b):s,$e=(b?.name??h).replace(' (example)',''),ze='owner'===Ee?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Ae=e=>(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Fe=e=>{const t=(0,A.pageFor)(e);return!t||t.can&&!t.can(s)?(0,X.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,X.jsx)(t.C,{go:Oe})})};return(0,X.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,X.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>oe?Y(je.current):ie(!0),children:(0,X.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:oe?'Skip to main content':'Open the owner tools menu'})}),(0,X.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,X.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:te,headerExtra:(0,X.jsx)(J,{open:re,onPress:()=>ie(!0)}),subHeader:(0,X.jsx)(Q,{name:$e,access:ze,day:He,at:Me})}),oe&&Pe?(0,X.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,X.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,X.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,X.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:oe.page?'Back to all settings':`Close ${oe.btn.label}, back to the floor plan`,onPress:()=>oe.page?ne({...oe,page:null}):ne(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,X.jsx)(f.T,{weight:"semibold",center:!0,children:oe.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,X.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,X.jsx)(l.default,{ref:je,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,X.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:We})}),(0,X.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,_.deskCopy)(Le?.sub??oe.btn.hint)})]}),(0,X.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,X.jsx)(J,{testID:"desk-menu-button-page",open:re,onPress:()=>ie(!0)})})]}),Ie.length>1&&!oe.page?(0,X.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Ie.map(e=>{const t=e.id===oe.tab;return(0,X.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>ne({btn:oe.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?Z:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,X.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,X.jsx)(i.default,{ref:we,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(!oe||!Pe)return null;if(oe.page)return Fe(oe.page);switch(oe.tab){case'@desk-bookings':return(0,X.jsx)(K.DesktopBookings,{filterRef:ye});case'@desk-hours':return(0,X.jsx)(K.DesktopHours,{go:Oe,filterRef:ye});case'@desk-takings':return Ce?(0,X.jsx)(K.DesktopTakings,{go:Oe}):(0,X.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,X.jsx)(K.DesktopSettings,{open:e=>ne(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,X.jsx)(G.DeskPermissions,{});case'@desk-leavers':return(0,X.jsx)(G.DeskLeavers,{});case'@desk-temps':return Ae((0,X.jsx)(G.DeskTemps,{}));case'@desk-bookinghistory':return Ae((0,X.jsx)(G.DeskCoversHistory,{}));case'@bookings':return(0,X.jsx)(H.Bookings,{go:Oe});case'@chat':return(0,X.jsx)(M.Chat,{go:Oe});case'@noshows':return Ae((0,X.jsx)(W.NoShows,{go:Oe}));case'@orders':return(0,X.jsx)($.Orders,{});case'@forecast':return(0,X.jsx)(E.Forecasts,{go:Oe});default:return Fe(oe.tab)}})()})]}):null]}),(0,X.jsx)(ee,{visible:re,buttons:De,current:oe?.btn.id,W:te,H:se,onClose:()=>ie(!1),onPick:e=>Se(e),onFind:()=>{ie(!1),ae(!0)},onKeys:()=>{ie(!1),ge(!0)},onInstall:()=>{ie(!1),pe(!0)},onSignOut:()=>{ie(!1),fe(!0)}}),le?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ae(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,X.jsx)(p.TextInput,{ref:ke,value:de,onChangeText:ce,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,X.jsx)(l.default,{'aria-live':'polite',children:(0,X.jsxs)(f.Muted,{center:!0,children:[Be.length," pages"]})}),Be.slice(0,60).map(e=>(0,X.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,X.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,X.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ue?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ge(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,_.SHORTCUTS)((0,F.isMac)()).map(([e,t])=>(0,X.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,X.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,X.jsx)(f.T,{center:!0,children:t})]},e)),(0,X.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,be?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>fe(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,X.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,X.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,X.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>fe(!1),testID:"desk-signout-cancel"}),(0,X.jsx)(f.Button,{label:me?'Signing out\u2026':'Sign out',disabled:me,onPress:async()=>{xe(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,he?(0,X.jsx)(f.Sheet,{visible:!0,onClose:()=>pe(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,X.jsx)(U.DesktopInstallPage,{})}):null,(0,X.jsx)(k.SeatAllergenReminder,{rid:e}),(0,X.jsx)(x.PrintHost,{rid:e}),(0,X.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Oe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,X.jsx)(z.OnboardingHost,{go:Oe}),(0,X.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]);r(d[37]);var F=r(d[38]),_=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]);const q=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Y=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},Z='rgba(201,162,74,0.14)';function J({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,X.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,X.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,X.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,X.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function Q({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,X.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,X.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,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function ee({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,V.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(()=>Y(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,F.isMac)();return(0,X.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,X.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,X.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,X.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,X.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,X.jsx)(l.default,{style:{width:56}}),(0,X.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,X.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,X.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,X.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,V.deskShortcut)(t,B);return(0,X.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,X.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:Z,alignItems:'center',justifyContent:'center'},children:(0,X.jsx)(G.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,X.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,X.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,X.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1556,[17,266,347,219,385,278,85,409,19,780,812,779,777,1229,1392,1087,1479,1086,1084,1231,1244,891,876,1032,1487,880,899,804,1339,1557,1057,1417,1160,1481,1483,1472,1456,1485,1553,1555,1563,1564,1565,1568,1571,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))}},1557,[17,266,347,219,385,278,85,409,780,779,1339,1456,1485,1417,1160,1483,1481,1057,1026,777,858,876,863,899,880,804,1558,1559,1560,1561,1562,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1558,[]); -__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])},1559,[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])},1560,[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])},1561,[17,385,1162,1163,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},1562,[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,b=Math.round(1.4*h),k=Math.max(48,Math.min(72,c-2*b-14,l-34));return{panelW:n,colW:l,per:c,circle:k,label:h,lineH:b,icon:Math.round(.44*k),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}],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'},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','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}`},1563,[1558]); -__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)},1564,[]); -__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,f.useOwner)(e=>e.staff),x=(0,f.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)),T=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=T.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,f.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,D.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,m.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,D.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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,D.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,D.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,f]=(0,t.useState)('next7'),[m,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[T,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,D.bookingColumns)(T),[T]),E=(0,t.useMemo)(()=>(0,D.sortRows)((0,D.filterRows)((0,D.bookingsBetween)(r,W,L,m),z,x),z.find(e=>e.key===$),M),[r,W,L,m,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:()=>f(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:m===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:T?'Hide phone numbers':'Show phone numbers',selected:T,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,D.csvName)('bookings',W,L),(0,D.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,D.ddmmyyyy)(W)}${L!==W?` to ${(0,D.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,D.ddmmyyyy)(W)} to ${(0,D.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,D.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${D.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,D.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",D.STATUS_WORD[G.status]??G.status]}),G.phone&&T?(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,f.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,m]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,T]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,f.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,D.ukTime)(e.in),outT:(0,D.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,D.sortRows)((0,D.filterRows)(O.filter(e=>'all'===p||e.status===p),D.HOURS_COLUMNS,y),D.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:m,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,D.csvName)('hours',R,M),(0,D.toCsv)(N,D.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,D.hm)((0,D.totalPaid)(N))} paid \xb7 ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`,cols:D.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(T(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,D.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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:T.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...T.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!T.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,T.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,T.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,T.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]),f=_r(_d[13]),m=_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]),T=_r(_d[23]),D=_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 f.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]}},1565,[17,385,85,409,812,777,1072,1032,1179,1122,1091,858,1008,876,1055,839,889,899,804,1417,1057,1456,1566,1555,1564,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}),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},1566,[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)}.`}},1567,[17,85,780,777,804,1566,1564,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}]},1568,[17,264,385,85,780,777,858,876,1569,915,1214,1463,804,1559,1057,1566,1570,1564,1567,1565,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)}))},1569,[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)},1570,[915]); -__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))})]})}},1571,[17,85,777,804,1572,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)},1572,[]); -__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:h,today:O,now:I,meId:N,me:X}=(0,A.useCtx)(3e4);(0,x.useTipsPosted)(e,O);const Z=(0,A.useSignedIn)();(0,m.useSoldOutLink)(!0,(Z?.name??X).replace(' (example)',''));const[q,J]=(0,s.useState)({kind:'tab',tab:'home'}),[Q,Y]=(0,s.useState)(''),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,A.ensureAttendance)(O,I),(0,D.ensureChat)(I)},[O]),globalThis.__ccNow=I.getTime();const te=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=V[t];return void J(e?{kind:'edit',id:e}:{kind:'page',id:t})}J('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:te}),()=>C.useVoiceNav.setState({go:null})),[te]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=te,globalThis.__deskGo=e=>J(e))},[te]),(0,v.useAlertWatcher)(e,{nag:'staff'!==h}),(0,w.useScheduledNotices)({rid:e,staffId:Z?.id??'',name:X,onOpen:e=>'bookings'===e?te('bookings'):'chat'===e?te('chat'):te('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==h&&!!Z});const ae=(0,s.useMemo)(()=>[...$,...F].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 ee.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=ae[Number(e.key)-1];return void(t&&(e.preventDefault(),J(t)))}if('z'===t&&!U(e.target)){const t=(0,z.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!U(e.target)){const t=(0,z.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae]);const se=B.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(h))&&!V[e.id]),ne=(0,s.useMemo)(()=>{const e=Q.trim().toLowerCase(),t={};return se.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[se,Q]),oe=$.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(h)),re=p.CAN.forecasts(h)?F:F.filter(e=>'rota'===e.s.id),ie='page'===q.kind?(0,B.pageFor)(q.id):void 0,le='tab'===q.kind?$.find(e=>K(e.s,q))?.label:'edit'===q.kind?F.find(e=>K(e.s,q))?.label:ie?.title,de='tab'===q.kind?$.find(e=>K(e.s,q))?.tip:'page'===q.kind?`${ie?.sub??''}. Press ${(0,_.CMD)()}K to jump to any page.`:'',ue=({label:e,s:t,n:a})=>{const s=K(t,q);return(0,W.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>J(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,W.jsx)(f.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,W.jsxs)(f.T,{size:11,colour:S.colours.muted,children:[(0,_.CMD)(),a]}):null]})},ce=({t:e})=>(0,W.jsx)(f.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),be='owner'===h?'OWNER':'manager'===h?'MANAGER':'STAFF';return(0,W.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,W.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,W.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(f.Row,{gap:10,children:[(0,W.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(u.VenueName,{name:c.name}),(0,W.jsx)(f.Row,{gap:6,children:(0,W.jsx)(l.AppBadge,{label:be})})]})]}),(0,W.jsx)(u.PoweredBy,{}),(0,W.jsx)(a.TextInput,{ref:ee,testID:"side-filter",value:Q,onChangeText:Y,placeholder:`Find a page (${(0,_.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[f.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,W.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Q?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{t:"Run the day"}),oe.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:t+1},e.label)),(0,W.jsx)(ce,{t:"Drag-and-drop editors"}),re.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:oe.length+t+1},e.label))]}),Object.entries(ne).map(([e,t])=>(0,W.jsxs)(r.default,{children:[(0,W.jsx)(ce,{t:e}),t.map(e=>(0,W.jsx)(ue,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,W.jsxs)(r.default,{style:{flex:1},children:[(0,W.jsx)(r.default,{testID:"desk-title",children:(0,W.jsx)(f.T,{size:24,weight:"bold",children:le??''})}),(0,W.jsxs)(f.Muted,{size:12,children:[Z?`Signed in as ${Z.name} \xb7 ${p.ROLE_LABEL[h]}`:`Preview \xb7 ${p.ROLE_LABEL[h]}`," \xb7 ",c.name]})]})}),(0,W.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[de?(0,W.jsx)(H.Tip,{children:de}):null,'edit'===q.kind?(0,W.jsx)(G,{id:q.id,rid:e,me:X,role:'owner'===h?'owner':'manager',today:O,venue:c.name}):(0,W.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===q.kind&&'home'===q.tab?(0,W.jsx)(L.Dashboard,{go:te}):null,'tab'===q.kind&&'orders'===q.tab?(0,W.jsx)(P.Orders,{}):null,'tab'===q.kind&&'bookings'===q.tab?(0,W.jsx)(E.Bookings,{}):null,'tab'===q.kind&&'forecast'===q.tab?(0,W.jsx)(R.Forecasts,{go:te}):null,'tab'===q.kind&&'chat'===q.tab?(0,W.jsx)(D.Chat,{go:te}):null,ie?(0,W.jsx)(ie.C,{go:te}):'page'===q.kind?(0,W.jsx)(f.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,W.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==h?(0,W.jsx)(g.PrintHost,{rid:e}):null,'staff'!==h?(0,W.jsx)(b.AlertHost,{variant:"managers",rid:e,me:X,onOpen:e=>te('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,W.jsx)(M.OnboardingHost,{go:te}),(0,W.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]),f=_r(d[12]),h=_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]);_r(d[33]);var O=_r(d[34]),_=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]);const $=[{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.'}],F=[{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:''}],V={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},K=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),U=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function G({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,h.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,W.jsx)(I.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,W.jsx)(N.RotaEditor,{today:o}):'brand'===e?(0,W.jsx)(O.BrandEditor,{rid:t}):(0,W.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,W.jsxs)(H.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,_.CMD)(),"Z undoes, then Save."]}),g?(0,W.jsx)(f.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,W.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,W.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{h.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)})]})}},1573,[813,812,17,385,278,85,19,1362,857,1365,1229,1392,777,998,876,891,1032,1479,1087,1086,1084,1487,1231,880,804,1417,1160,1057,1430,1481,1472,1483,1456,1485,1574,1553,1576,1578,1580,1577,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])},1574,[17,278,85,1500,857,777,876,814,1457,804,1575,1576,1577,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)})},1575,[]); -__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},1576,[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})},1577,[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."})]})]})}},1578,[812,17,85,777,860,816,891,893,894,845,867,1152,804,1575,1576,1577,1579,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])},1579,[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)}`},1580,[17,85,777,876,1060,804,1575,1576,1577,1051,1579,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]})}},1581,[13,17,856,1582,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)','')}})}},1582,[1457,1583,813,912,1072,1509,1208,1209,1028,1025,1026,1510,1544,1512,1152,891,978,1584,975,880,1031,1032,1493,914,1008,915,17,1154,1240,1244,1202,356,385,278,85,409,19,777,857,876,804,1160,1417,1066,1084,1086,1081,1027,1010,1057,1503,1498,1525,1585,1425,920,219,1245,1181,1187,1455,1201,1198,1480,1184,878,1211,1212,884,776,899,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']]},1583,[17,85,777,1057,899,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}},1584,[219,976]); -__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)','')},1585,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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]})}},1586,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1587,[1450,899,778,1411,1588,995,13,1615,479,17,368,319,219,24,85,805,857,1065,856,1617,19,858,998,876,804,1425,920,988,1618,1619,1028,1104,880,1008,914,1621,1381,8,1622,1623,1624,1625]); -__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])},1588,[1589,1612,1614]); -__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)}}},1589,[198,1590,1593,1607,1608,1609,1610,1611]); -__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}},1590,[198,1591]); -__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}},1591,[1592]); -__d(function(g,r,i,a,m,e,d){},1592,[]); -__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)}},1593,[1594,198,1590,1607,1608]); -__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]}})})},1594,[1595,1596,1606]); -__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()}})}},1595,[1596,1600,1605]); -__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}}},1596,[198,355,1597,1601,1602,1603,1604,1600,1605]); -__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}},1597,[198,1598,322,263,1599,1600]); -__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])},1598,[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}}},1599,[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},1600,[]); -__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}},1601,[]); -__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}},1602,[]); -__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])},1603,[1601]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},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}),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},1605,[355,1599]); -__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])},1606,[17,1596]); -__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}},1607,[1594,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])},1608,[1594,1607]); -__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}},1609,[1590]); -__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])},1610,[198,1590,1593,1591]); -__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})({})},1611,[]); -__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]))},1612,[198,37,1613]); -__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')},1613,[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]}},1614,[17,1589]); -__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]}})})},1615,[1616]); -__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(){}},1616,[]); -__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]})}},1617,[17,24,85,409,777,857,920,899,880,805,804,1558,1560,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()})},1618,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1619,[813,779,17,974,385,85,856,899,976,804,777,1351,971,880,1620,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1620,[17,1458,385,85,899,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1621,[]); -__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"},1622,[]); -__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"},1623,[]); -__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"},1624,[]); -__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"},1625,[]); -__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]})}},1626,[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},1627,[1628]); -__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},1628,[8,1629,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}))}}},1629,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1630,[]); -__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})}}},1631,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1278,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1279,[17,385,85,409,777,804,1190,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1280,[17,85,1281,777,858,920,1260,1263,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1281,[17,85,1282,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1282,[1283]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1283,[17,780,1284,1313,1314,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1284,[1285]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1285,[1286,1287,1310,1312]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1286,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1287,[1288,1289,1290,1291,1292,1293,1294,1295,1296,1299,1303,1300,1304]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1288,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1289,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1290,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1291,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1296,[1297]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1300,[1301,1302]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1301,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1302,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1305,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1306,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1308,[1300,1288]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1309,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1310,[1311]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1312,[1311]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1313,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1314,[17,780,1315,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1315,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1316,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1317,[822,13,17,85,1281,777,851,858,804,1280,1263,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1318,[822,13,17,85,1258,777,858,876,851,863,804,1259,1263,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1319,[822,13,17,777,858,876,863,804,1280,1263,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1320,[822,13,17,777,858,876,804,1280,1263,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1321,[13,17,777,863,1140,1322,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1322,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1323,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1324,[843,13,17,1249,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1325,[13,17,85,1254,777,845,862,858,804,1279,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1326,[13,17,1327,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1327,[17,85,777,1099,804,1328,1329,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1328,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1329,[928,971,1328]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1330,[843,13,17,85,1256,777,845,851,863,858,804,1331,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1331,[17,354,362,219,13,777,851,804,900,1332,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1332,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1333,[843,1263,13,17,85,777,845,851,863,858,864,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]})}},1334,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1335,[822,13,17,777,858,805,1263,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1336,[13,17,777,1337,1154,1263,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1337,[812,843,17,85,777,845,851,1154,1338,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1338,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1339,[13,17,856,1340,1412,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1340,[1053,779,805,806,1341,813,1342,1094,843,1140,1343,1344,1345,1091,1122,1346,1347,1352,1353,1210,1354,856,1359,1360,1361,1115,1113,920,1362,1153,891,1104,1363,17,1072,1185,1018,1087,1364,21,378,363,385,278,85,409,19,777,1241,1245,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1365,1108,1366,1372,1374,1378,1383,1377,1384,1387,1388,1117,1095,1096,862,1393,1230,1394,1240,1232,995,1399,1404,1405,1054,1052,1119,1407,1408,1409,1071,1172,1410,1171,1162,853,1355,1411,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1343,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1344,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1345,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1346,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1347,[17,378,385,409,85,1281,777,1172,779,998,1348,1349,1351,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1348,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1349,[17,378,385,278,395,85,409,779,777,804,1350,1351,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1350,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1351,[993,856,1350,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1352,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1353,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1354,[1168,17,219,385,85,777,1167,804,876,920,1355,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1355,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1356,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1356,[831,928,899,1357,880,1358]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1357,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1358,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1359,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1361,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1362,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1363,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1364,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1365,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1366,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1367,1369,1368,998,876,1108,1370,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1367,[813,843,17,1368,85,842,804,777,1109,1369,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1368,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1369,[1368,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1370,[17,368,278,85,842,982,1371,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1371,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1372,[17,219,385,85,804,777,1172,1373,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1373,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1374,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1375,841,863,1096,1376,804,777,1377,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1375,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1376,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1377,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1378,[805,813,17,266,319,219,385,85,409,804,857,1379,777,999,916,1352,1381,880,1382,1383,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1379,[17,219,85,1380,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1380,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1381,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1383,[17,831,928,899,1382]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1384,[843,841,998,1385,1386]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1385,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1386,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1387,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1388,[1389,843,1095,998,17,85,777,1098,858,1116,1384,1096,863,1093,1117,1118,1119,804,1344,1391,1392,1115,1361,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1389,[17,362,385,85,858,920,876,996,1390,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1390,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1393,[1172,1389,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1377,858,998,845,1089,1076,1322,804,1344,1391,1392,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1394,[812,17,219,385,85,777,858,998,1395,804,1396,1398,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1395,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1396,[831,858,998,1395,1397,1398]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1397,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1398,[219,1397]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1399,[843,17,1189,1172,385,85,995,998,862,863,804,777,1400,1403,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1400,[1401,854,843,17,264,378,385,278,85,858,995,998,1402,863,804,1026,777,1403,1356,899,1344,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1401,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1402,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1403,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1405,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1406,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1407,[843,1385]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1408,[17,385,85,777,1407,804,1364,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1409,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1410,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1411,[17,1005,876,926,816,1006,916,1356,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1412,[805,813,857,17,219,385,85,409,899,804,777,1352,1413,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1413,[]); +__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]})}},1414,[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]})}},1415,[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,{})}},1416,[13,17,1417,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])},1417,[17,856,1418,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}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return H.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]),Y=_r(d[45]);_r(d[46]);var 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,Q.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,Q.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,K.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,K.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,J.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)(()=>{G.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,M.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)(z.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)(z.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'!==H.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'===H.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'===H.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.jsx)(D.AssistantRequestsButton,{go:Be,testID:"assistant-requests-top"}),(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'===H.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)(F.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(Y.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(U.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(Q.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(K.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.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)(W.OnboardingHost,{go:Be}),(0,le.jsx)(V.CoachHost,{})]})}},1418,[805,813,899,1193,1228,1210,1028,1025,891,1026,880,1032,1087,17,356,378,385,278,409,85,19,777,857,858,876,804,1419,1184,1057,884,1427,920,219,1432,1472,839,856,1474,1481,1482,1483,1190,1246,1484,1458,1485,1487,1456,1161,1230,1394,1232,1245,1489,1084,1086,1555,1556,1575,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1419,[805,1420,1095,1270,1421,812,822,1117,1118,1091,1122,1422,1114,1119,1407,1408,1057,1344,996,1120,1089,841,1386,1125,1424,1241,1425,1399,1078,1055,1090,17,85,777,1364,858,845,851,863,1322,804,1184,1098,1115,998,1361,1062,1162,1426,1232,899,1186,1404,862,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1420,[]); +__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])},1421,[806,17,85,777,899,1274,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1422,[17,385,85,1423,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1423,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1424,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1187,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1425,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1426,[17,85,864,858,848,804,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1427,[1428,17,219,24,85,856,1429,920,804,1431,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1428,[]); +__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])},1429,[17,278,85,777,857,804,1430,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(' ')},1430,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1431,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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:n=!1}){const{rid:a,r:x,now:H,role:ae,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(a),ce=(0,p.useBookings)(a),ue=(0,p.useWaitlist)(a),ge=(0,p.useEvents)(a),xe=(0,p.useRatings)(a),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,S.useRealHistory)(a,H),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,H,pe??void 0),[x,ce,de,ge,pe,H.getTime()/6e4|0]),ke=(0,M.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),Ie=de.filter(B.LIVE),ve=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=Ie.filter(e=>(0,U.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,U.bookingNeedsAction)(e,Ie)),Ae=Ie.flatMap(e=>(0,I.readinessFor)(e,x,H).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Se=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Me=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,v.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(H),He=ke?(0,L.revenueHistory)(x,H,7).filter(e=>e.date.getDay()===H.getDay()).pop():void 0,Fe=ke?{today:186e3+Ne,last:He?{date:(0,v.ymd)(He.date),pence:He.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,a,Pe,Ne),We=j.CAN.takings(ae)&&(!(0,W.isLive)()||(0,W.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,H,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(H),(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)(ae,qe,{inStaffApp:Ye,live:(0,W.isLive)()}),Ve=(0,F.homeSetupNagsHidden)(a),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,st]=(0,l.useState)(!1),ot=ie.replace(' (example)',''),lt=j.CAN.manage(ae)?(0,ne.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,ne.jsxs)(b.default,{style:{gap:12},children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(i.DayView,{rid:a,day:Ue,today:re,app:"owner"})]}):(0,ne.jsxs)(b.default,{style:{gap:12},testID:n?'owner-home':'managers-home',children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(K.WhoBar,{}),qe&&'owner'!==qe.role?(0,ne.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ne.jsx)(X.MyTasksToday,{rid:a,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ae?(0,ne.jsx)(Z.TodaysTipsCard,{rid:a,today:re}):null,'staff'!==ae?(0,ne.jsx)(Z.TipsPotCard,{rid:a,today:re}):null,j.CAN.manage(ae)?(0,ne.jsx)(b.default,{testID:"home-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.jsx)(f.Button,{testID:"home-insights-toggle",kind:tt?'secondary':'primary',label:tt?'Hide insights':'Insights',accessibilityLabel:tt?'Hide insights':'Insights: business insights, stats and suggestions. Closed until you tap.',onPress:()=>st(e=>!e),style:{minHeight:56,width:'100%'}})}):null,j.CAN.manage(ae)&&tt?(0,ne.jsxs)(b.default,{testID:"home-insights-panel",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,ne.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.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%'}})}),(0,ne.jsx)(le.SuperProInsights,{go:e}),(0,ne.jsxs)(b.default,{testID:"home-insights-feed",style:{gap:12,width:'100%'},children:[(0,ne.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,ne.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ne.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,ne.jsxs)(f.T,{weight:"semibold",center:!0,children:[t.icon," ",t.title]}),(0,ne.jsx)(f.Muted,{center:!0,children:t.body}),t.action?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'center'}}):null]})},t.id)),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights'),style:{alignSelf:'center'}})]})]}):null,(0,ne.jsx)(ye,{split:De}),(0,ne.jsx)(te.BlocksBanner,{rid:a,now:H,by:ie}),(0,ne.jsx)(y.KitchenSignoffs,{rid:a,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(o.SeasonsTodo,{go:e}):null,(0,ne.jsx)(r.LastFoodBanner,{rid:a,now:H}),(0,ne.jsx)(d.NextTableFreeCard,{rid:a,now:H}),j.CAN.manage(ae)?(0,ne.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,ne.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,ne.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ne.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ae)?(0,ne.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:a,r:x,now:H,by:ie}):null]}),ze.elements,j.CAN.manage(ae)?(0,ne.jsx)(Y.PaydaysCard,{go:e}):null,(0,ne.jsx)(E.FadeIn,{children:(0,ne.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ne.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,ne.jsx)(S.ExampleBadge,{}):je.enough?(0,ne.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ne.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ne.jsx)(E.Gauge,{pct:Le?Se.pct:0,label:Le?Se.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,ne.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ne.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,je.enough?(0,ne.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,ne.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ne.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ne.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||Ie.length?(0,ne.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Live orders",value:"",accent:Ie.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${Ie.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${Ie.filter(e=>'table'===e.type).length} table`:`${Ie.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ne.jsx)(E.CountUp,{value:Ie.length})})}):null,ve.length>0?(0,ne.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ne.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,ne.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(z.TakingsTodayCard,{t:Fe,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ne.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ne.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,ne.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,ne.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ne.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,v.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ne.jsx)(f.T,{size:14,children:t.detail}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ge.days.length||Ge.requests)?(0,ne.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,ne.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ae)?(0,ne.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ne.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ne.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ne.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,ne.jsxs)(f.Row,{gap:4,children:[(0,ne.jsx)(G.Mark,{p:"facebook"}),(0,ne.jsx)(G.Mark,{p:"instagram"}),(0,ne.jsx)(G.Mark,{p:"tiktok"}),(0,ne.jsx)(G.Mark,{p:"youtube"})]}),(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ne.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ne.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ne.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ne.jsx)(B.SectionHead,{title:e})}),(0,ne.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ne.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ne.jsxs)(f.Card,{children:[0===Oe.length?(0,ne.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,ne.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ne.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,v.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ne.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ne.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),Ke?(0,ne.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,ne.jsx)(E.FadeIn,{children:(0,ne.jsx)(he,{rid:a,today:re})}):null,'owner'!==ae||V.IS_CAR?null:(0,ne.jsx)(f.Button,{testID:"home-customer-support",label:"Customer support",accessibilityLabel:"Customer support, send a message or a picture to CoverCharge",onPress:()=>e('more','support'),style:{minHeight:56,width:'100%'}}),(0,ne.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:a,by:ot,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]),n=_r(_d[4]),a=e(n),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]),I=_r(_d[21]),v=_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]),S=_r(_d[29]),M=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),H=_r(_d[33]),F=_r(_d[34]),W=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),_=_r(_d[41]),U=_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]),ne=_r(_d[56]);const ae=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 a=3/Math.sqrt(n);o[e]=a*t*s[e],o[e+1]=a*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)&&n.push(e);for(;n.length&&o(e)-o(n[n.length-1])<36;)n.pop();return[...n,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&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/I*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:v(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],S=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?.(M(s)))},M=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,F=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,W=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)} ${F}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${W?` ${W.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,n)=>(0,ne.jsx)(m.default,{testID:n,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,ne.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ne.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ne.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ne.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ne.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,ne.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,ne.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ne.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:F}),(0,ne.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),W?(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:W}):null]}):(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ne.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ne.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ne.jsxs)(a.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ne.jsx)(n.Defs,{children:(0,ne.jsxs)(n.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ne.jsx)(n.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ne.jsx)(n.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ne.jsx)(n.Line,{x1:ae,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.Circle,{cx:v(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ne.jsx)(n.Line,{x1:v(L.day),y1:10,x2:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:M(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:v(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ne.jsx)(b.default,{testID:"mt-axis",style:{height:H.AXIS_BAND+6,minHeight:H.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ne.jsx)(f.T,{size:H.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:v(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ne.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ne.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>S(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ne.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:M(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ne.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ne.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,ne.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>S(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,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ne.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: card + cash \u2212 card tips. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ne.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ne.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,ne.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ne.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ne.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,ne.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ne.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1432,[843,1140,1433,17,780,1185,1074,1075,1425,1344,861,1078,264,385,85,777,858,876,1211,1193,845,1160,863,1055,866,804,1184,1057,1139,1145,1146,1008,839,1150,886,899,915,1443,1444,1149,1445,1162,853,1448,1188,1209,856,1207,1031,1032,1066,1098,1399,1153,1343,1466,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."})]})}},1433,[1053,1033,805,1420,812,1434,1435,1437,1438,1439,1203,1031,1032,1008,1014,17,385,85,777,841,1440,816,862,1055,861,804,1057,858,1187,926,927,876,1441,1394,998,1442,1005,1142,892,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)},1434,[812,17,85,777,1140,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)},1435,[843,17,219,85,777,858,998,1154,1263,899,1338,1436,8]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1436,[843,1285]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1437,[17,85,777,998,1348,804,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1438,[17,85,777,998,863,1402,805,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1439,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1440,[17,1033,85,804,777,1260,1263,8]); +__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1441,[17,85,777,998,1368,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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),S=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>C(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>C(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>f(null),onSave:t=>{y.update(e.id,t),f(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",S(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>f(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:I,onCancel:()=>f(null),onSave:t=>{y.add(e,t),f(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>f('new')}),(0,k.jsxs)(r.Sheet,{visible:!!p,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:p?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{p&&y.remove(p.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{f.useOrderLists.getState().ensure(e)},[e]);const s=(0,f.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,f.orderSettingsOf)(e);(0,f.useOrderLists)(t=>t.settings[e]);const l=f.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),f=(0,s.privateClockVenue)(e),[p,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[S,v]=(0,n.useState)(!1),[C,I]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(f)return;v(!0),I('');const t=await(0,b.getFix)();if(v(!1),'object'!=typeof t)return void I('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),I(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:f?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),f?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),f?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:S?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:S,onPress:()=>{B()}}),C?(0,k.jsx)(r.Muted,{size:13,children:C}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:p,onChangeText:j,onBlur:()=>R(p,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(p,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),f?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"The full CookSafe log is in the food safety menu: CookSafe log."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_r(_d[5])),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},S=[1,2,3,4,5,6,0],v=['on_shift','everyone','managers','head_chef','kitchen','foh'],C=e=>e.replace(' (example)',''),I={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:C(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[v.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:C(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,f]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),p=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{f(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:S.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),p?(0,k.jsx)(r.Muted,{size:13,children:p}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!p,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>f.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1442,[812,912,17,362,385,85,777,804,1005,1006,876,1010,1011,1012,913,1068,899,1029,916,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1443,[]); +__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7])},1444,[17,385,85,777,804,1149,1443,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1445,[886,779,816,813,822,862,1039,1446,17,909,319,362,219,385,85,777,858,876,863,804,1184,1057,1221,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1446,[482,1447]); +__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}});var t={}},1447,[]); +__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.ProgressBar=L,_e.useSetupDone=F,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,T.useCtx)(6e4),n=F(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=k.SETUP_STEPS.findIndex(e=>e.id===a),s=k.SETUP_STEPS[e+1]?.id??null;return(0,R.jsx)(A,{id:a,wizard:!0,onBack:()=>l(e>0?k.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=k.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,R.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{gap:12,children:[(0,R.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsxs)(m.T,{size:20,weight:"bold",colour:C.colours.gold,children:["Set up ",t.name]}),(0,R.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,R.jsx)(L,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,R.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,R.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:C.colours.border,backgroundColor:C.colours.surface,overflow:'hidden'},children:k.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,R.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:C.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,R.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?C.colours.gold:'transparent',borderWidth:1.5,borderColor:t?C.colours.gold:C.colours.border},children:(0,R.jsx)(m.T,{weight:"bold",colour:t?C.colours.onGold:C.colours.muted,children:t?'\u2713':s+1})}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"medium",children:e.title}),(0,R.jsx)(m.Muted,{children:e.sub}),o.length?(0,R.jsxs)(m.T,{size:13,colour:C.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,R.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=A,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return V}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=F(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,R.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",colour:C.colours.gold,children:"Finish setting up"}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]}),(0,R.jsx)(L,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,R.jsxs)(m.Muted,{size:13,children:["Next: ",k.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]),M=_r(_d[29]),R=_r(_d[30]);const I=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=[1,2,3,4,5,6,0],B=/^([01]\d|2[0-3]):[0-5]\d$/,D=e=>{const s=(0,M.parseMoneyInput)(e);return null!=s&&s>0?Math.round(100*s):null},O=e=>k.SETUP_STEPS.findIndex(s=>s.id===e)+1;function L({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,R.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,R.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:C.colours.gold,borderRadius:5}})}),(0,R.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function F(e){const s=(0,k.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=k.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:k.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function A({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,T.useCtx)(6e4),l=F(a),r=l.prog,d=(0,i.useLiveVenue)(),u=k.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=N[e];return(0,R.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsxs)(m.T,{size:12,weight:"semibold",colour:C.colours.gold,children:["STEP ",O(e)," OF ",k.SETUP_STEPS.length]}),s&&o?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,R.jsx)(m.T,{size:13,colour:C.colours.muted,children:"All steps"})}):null]}),(0,R.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,R.jsx)(L,{done:r.done,total:r.total})]}),(0,R.jsx)(b,{rid:a,done:(t="Saved.")=>{k.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,R.jsx)(m.Banner,{kind:"success",title:p}):null,(0,R.jsx)(G,{rid:a,id:e,title:u.title,onDone:x}),s?(0,R.jsxs)(m.Row,{gap:10,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,R.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const U=({wizard:e,onPress:s,disabled:t,label:n})=>(0,R.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const _=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function W({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,T.useHourly)(),d=(0,k.useSiteSetup)(e),u=(0,k.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,f]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,S.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,k.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),f(null)},z=!!p?.id&&(E=p.id,w.ROSTER.some(e=>e.id===E));var E;const M=p?D(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=M||z&&!p.wage);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,R.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,R.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?C.colours.gold:C.colours.border,backgroundColor:s?'#1d1a14':C.colours.surface}),children:[(0,R.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"semibold",children:e.name}),(0,R.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,k.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,R.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,k.accessOf)(e.level,e.role)})]},e.id))}),y?(0,R.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:C.colours.gold},children:(0,R.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,R.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,R.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,R.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,R.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,R.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Access level"}),(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:k.ACCESS_LEVELS.map(e=>(0,R.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,R.jsxs)(m.Muted,{size:13,children:["Uses the ",k.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Pay"}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,R.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,R.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,R.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,R.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,S.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,R.jsx)(m.Field,{money:!0,label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=M&&M<1271?(0,R.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,R.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,R.jsxs)(m.Row,{gap:8,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,R.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),k.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:k.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=M&&s.setRate(t,M);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),k.useSetup.getState().patch(e,{staffGrade:o}),k.useSetup.getState().setLook(t,p.look),f(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,R.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,R.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(_(d.grades[0]?.id??'')),f(null)}}),(0,R.jsx)(U,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const N={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,k.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,R.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,R.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,R.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,R.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':(0,y.builtInLogoCopy)(e)," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,R.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,R.jsx)(z.OrderAtTableCard,{rid:e,compact:!0}),u?(0,R.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,R.jsx)(U,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,T.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=$.filter(e=>{const s=n[e];return s&&(!B.test(s[0])||!B.test(s[1]))});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),I.map((e,s)=>{const t=$[s],l=n[t];return(0,R.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:C.colours.border,paddingTop:s?6:0},children:[(0,R.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,R.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"to"}),(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,R.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,R.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries($.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,R.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,R.jsx)(U,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,f.usePlan)(e),o=(0,f.planCounts)(n);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P.TablePlan,{startStep:"areas"}),(0,R.jsx)(U,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,R.jsx)(W,{...e,payList:!0})]})},staff:W,permissions:function({done:e,wizard:s}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E.PermissionsScreen,{}),(0,R.jsx)(U,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,k.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,R.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,R.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,R.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,R.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,R.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,R.jsx)(U,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),a=(0,k.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,v.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,R.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,R.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:C.colours.border,padding:10},children:(0,R.jsx)(m.T,{size:14,colour:C.colours.goldLight,children:i})}),(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,v.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,R.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,R.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,R.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,R.jsx)(U,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),k.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,T.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,R.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,R.jsx)(U,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},V=e=>function(){return(0,R.jsx)(A,{id:e})};function G({rid:e,id:s,title:t,onDone:n}){const o=F(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,R.jsxs)(g.default,{style:{gap:4},children:[(0,R.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),k.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,R.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,R.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1448,[888,887,813,812,1039,1449,1450,1451,1452,1454,17,385,85,857,884,777,858,876,1455,998,886,878,851,804,1057,1456,1459,1463,1464,840,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1449,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1450,[17,899]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1451,[17,831,899]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1452,[880,812,17,219,366,85,777,1453,899,804,1188,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1453,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1454,[17,385,777,899,804,1452,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.builtInLogoCopy=function(o){return'anchorage'===o?'The Anchorage logo in black and gold.':'Placeholder initials.'}},1455,[]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1456,[812,891,1140,899,780,1230,1232,17,264,362,219,385,85,409,864,777,858,1241,876,851,863,804,1184,1057,853,1055,1445,1161,1457,1458,1139,1146,1145,1008,839,1142,1149,1221,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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1457,[812,17,1228,1026,854,362,385,85,777,876,851,863,804,1184,1057,1221,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1458,[978,17,385,85,777,876,804,1057,1161,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1459,[812,17,1018,378,85,1108,1109,1366,1399,777,995,998,863,804,1057,999,1460,1461,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1460,[812,17,385,85,777,804,998,805,999,856,899,8]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1461,[17,85,777,998,1462,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1462,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1463,[805,1420,17,85,777,858,876,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.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 ')}},1464,[17,264,385,85,777,804,915,1465,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.'},1465,[928,899,876,856,915]); +__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 P}}),_e.useInsightsAccess=S,_e.SuperProInsights=_,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,D.jsx)(o.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,D.jsx)(_,{go:e})}):(0,D.jsx)(E,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.sales)return(0,D.jsx)(E,{});const r=i.sales;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Last 7 days"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=r.last7?(0,x.moneyGbp)(r.last7):'\u2014'}),r.missing7?(0,D.jsx)(l.Muted,{center:!0,children:`From ${r.days7} of ${r.days7+r.missing7} cash ups. ${r.missing7} ha${1===r.missing7?'s':'ve'} no card or cash total yet, so ${1===r.missing7?'it is':'they are'} not in the total.`}):null,(0,D.jsx)(l.Muted,{center:!0,children:null!=r.prev7?`The 7 days before: ${(0,x.moneyGbp)(r.prev7)}${null!=r.changePct?` (${r.changePct>=0?'up':'down'} ${Math.abs(r.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,D.jsx)(l.Muted,{center:!0,children:null!=r.sph7?`Spend per head ${(0,x.moneyGbp)(r.sph7)}, on the ${r.sphDays7} day${1===r.sphDays7?'':'s'} with takings and Covers`:'Spend per head shows once days have takings and Covers'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Takings by week"}),(0,D.jsx)(O,{values:r.weeks.map(e=>e.gross),w:300,h:70}),r.weeks.slice().reverse().map(e=>(0,D.jsx)(W,{a:`${(0,w.ukDate)(e.from)} \u2013 ${(0,w.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up${e.missing?`, ${e.missing} with no card or cash total`:''}`:e.missing?`Not enough data: ${e.missing} cash up${1===e.missing?'':'s'} with no card or cash total`:'No signed-off cash ups'},e.to)),(0,D.jsx)(l.Muted,{center:!0,children:"Takings are card + cash \u2212 card tips from signed-off cash ups (Gross only for a prepaid function), as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,D.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.stock)return(0,D.jsx)(E,{});const r=i.stock;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Low or out now"}),(0,D.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."}),r.low.length?r.low.map(e=>(0,D.jsx)(W,{testID:`low-${e.key}`,tone:e.out?k.colours.red:k.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,D.jsx)(l.Muted,{center:!0,children:r.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:`Price rises in the last ${w.RISE_DAYS} days`}),r.rises.length?r.rises.map(e=>(0,D.jsx)(W,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,$.gbp)(e.before)} \u2192 ${(0,$.gbp)(e.after)} a pack \xb7 ${(0,w.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,D.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,D.jsx)(l.Muted,{center:!0,children:r.lastCount?`Last full stock count ${(0,w.ukDate)(r.lastCount)}.`:'No full stock count yet.'})]}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.gp)return(0,D.jsx)(E,{});const r=i.gp;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,D.jsx)(A,{example:i.example}),i.example?(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:k.colours.gold,children:L(r.menu)}),null!=r.startMenu&&null!=r.menu?(0,D.jsx)(l.Muted,{center:!0,children:`${G(r.menu-r.startMenu)} points since ${(0,w.ukDate)(r.trend[0]?.week??'')}`}):null,(0,D.jsx)(O,{values:r.trend.map(e=>e.menu),w:300,h:80})]}):null!=r.menu?(0,D.jsx)(v.GpOverTime,{rid:s}):(0,D.jsx)(o.default,{testID:"insights-gp-not-enough",style:{width:'100%'},children:(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP"}),(0,D.jsx)(l.T,{weight:"semibold",center:!0,children:"Not enough data"}),(0,D.jsx)(l.Muted,{center:!0,children:`${r.fullyCosted} of ${r.costed} costed dishes have every recipe ingredient costed. Menu GP shows once ${w.MIN_FULLY_COSTED} or more are, so a part-costed dish cannot make GP look too high.`})]})}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),r.drops.length?r.drops.map(e=>(0,D.jsx)(W,{testID:`drop-${e.dishId}`,tone:k.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,w.ukDate)(e.date)}`},e.dishId)):(0,D.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Each dish over 3 months"}),r.dishes.length?r.dishes.map(e=>(0,D.jsx)(W,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const s=S(),n=C(),{list:i,source:r}=N(),[a,d]=(0,t.useState)('all');if(!s.clock)return(0,D.jsx)(E,{});const c='unsigned'===a?i.filter(e=>!1===e.signed):i,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,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,D.jsx)(A,{example:!!n}),(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${i.length})`,onPress:()=>d('all'),testID:"clock-filter-all"}),(0,D.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${i.filter(e=>!1===e.signed).length})`,onPress:()=>d('unsigned'),testID:"clock-filter-unsigned"})]}),(0,D.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:c.length?c.map(e=>(0,D.jsxs)(o.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${w.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,w.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:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?k.colours.amber:k.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,w.ukDate)(e.workDate)}`}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,children:`${w.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,D.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,D.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,D.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,D.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${w.CLOCK_DAYS} days.`})}),(0,D.jsx)(l.Muted,{center:!0,children:'server'===r?'From the server\u2019s timesheet audit.':'synced'===r?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=_r(_d[1]),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=e(i),l=_r(_d[5]),a=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),$=_r(_d[15]),x=_r(_d[16]),w=_r(_d[17]),b=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),D=_r(_d[23]);const P='SuperPro';function S(){const{role:e}=(0,j.useCtx)(6e4),s=(0,j.useSignedIn)(),t=(0,j.useInStaffApp)();return(0,w.insightsAccess)({viewRole:e,signed:s,live:(0,b.isLive)(),inStaffApp:t,perm:e=>(0,b.can)(e)})}function C(){return(0,y.useExamples)()&&!(0,b.isLive)()?I.INSIGHTS_SAMPLE:null}function N(){const e=C(),s=(0,h.useOwner)(e=>e.attendance),n=(0,h.useOwner)(e=>e.staff),[o,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(e||!(0,b.isLive)())return;let s=!0;return(0,b.readClockChanges)(w.CLOCK_DAYS).then(e=>{s&&e&&i((0,w.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,t.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const t=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:t(o),source:'server'};const i=(0,w.addDaysYmd)((new Date).toISOString().slice(0,10),-w.CLOCK_DAYS);return{list:t((0,w.clockChangesFromAttendance)(s,i)),source:'synced'}},[e,o,s,n])}function M(e){const s=C(),[n,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(s||!e||!(0,b.isLive)())return;let t=!0;return(0,b.readLoyaltyInsight)().then(e=>{t&&o(e?(0,w.loyaltyInsight)(e.raw,e.source):null)}),()=>{t=!1}},[s,e]),s?s.loyalty:e&&(0,b.isLive)()?n:null}function T(e,n){const o=C(),i=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,a.useBookings)(e),y=(0,a.useOrders)(e),$=(0,d.useReviews)(e=>e.reviews),x=(0,h.useOwner)(e=>e.attendance),b=(0,j.useHourly)(),k=(0,u.useGpCalcView)(),v=(0,a.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),D=(0,g.useShellStore)((0,f.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,t.useMemo)(()=>{if(o)return{example:!0,...o};const t=v.map(e=>({id:e.id,dish:e.dish,price:e.price,ingCount:Array.isArray(e.ingredients)?e.ingredients.length:void 0})),a=new Date,d=(0,w.salesInsight)(i,l,e,n,(0,s.coverOverridesFor)(e)),c=x.filter(e=>!e.voided&&'confirmed'===(0,h.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,j.paidMins)(e,a).paid,ratePence:b[e.staffId]??0})),u=x.filter(e=>!e.voided&&'awaiting'===(0,h.attStatus)(e)).map(e=>e.date);return{example:!1,sales:d,stock:(0,w.stockInsight)((I??[]).filter(e=>!e.group),D,(s,t)=>(0,p.fmtStockCount)(e,s,t),k.ingredients,Object.values(k.counts??{}),n),gp:(0,w.gpInsight)(k.ingredients,k.cardCosts??{},t,k.settings,Object.values(k.deliveries??{}),n),bookings:(0,w.bookingsInsight)(l,e,n),orders:(0,w.ordersInsight)(y,e,n),reviews:(0,w.reviewsInsight)($,e,n),labour:(0,w.labourInsight)(c,i,e,n,u),salesReport:(0,w.salesReportInsight)(r,e)}},[o,i,r,l,y,$,x,b,e,n,k,v,I,D])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,G=e=>`${e>0?'+':''}${e.toFixed(1)}`;function O({values:e,w:s=220,h:t=44,testID:n}){const l=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(l.length<2)return null;const a=Math.min(...l.map(e=>e.v)),d=Math.max(...l.map(e=>e.v))-a||1,c=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/d*(t-12),h=l[l.length-1];return(0,D.jsx)(o.default,{testID:n,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,D.jsxs)(r.default,{width:s,height:t,children:[(0,D.jsx)(i.Polyline,{points:l.map(e=>`${c(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:k.colours.gold,strokeWidth:2.5,fill:"none"}),(0,D.jsx)(i.Circle,{cx:c(h.i),cy:u(h.v),r:3.5,fill:k.colours.gold})]})})}function R({title:e,big:s,line:t,tone:o,onPress:i,testID:r,children:a,a11y:d,plan:c}){return(0,D.jsxs)(n.default,{testID:r,accessibilityRole:"button",accessibilityLabel:d,accessibilityHint:"Opens the detail",onPress:i,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??k.colours.gold,backgroundColor:e?k.colours.goldTint:k.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:e}),c?(0,D.jsx)(l.T,{size:11,weight:"semibold",colour:k.colours.goldLight,center:!0,children:c.toUpperCase()}):null,(0,D.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??k.colours.text,children:s}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.muted,children:t}),a,(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.goldLight,children:"Open \u203a"})]})}function A({example:e}){return(0,D.jsxs)(o.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.T,{size:20,weight:"bold",colour:k.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,D.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,D.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function B({title:e,sub:s,children:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.Badge,{kind:"gold",label:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]}),(0,D.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function _({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t),r=N(),l=M(n.loyalty);if(!n.any)return null;const a=(0,w.clockSummary)(r.list),d=(0,w.loyaltyLine)(l),c=s=>e('more',s),u=i.sales,h=i.stock,g=i.gp,p=i.bookings,f=i.orders,y=i.reviews,b=i.labour,v=i.salesReport,I=e=>w.INSIGHT_PLAN[e],C=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=n.sales||n.stock||n.gp||n.clock,E=n.bookings||n.noshows||n.orders||n.loyalty||n.reviews||n.labour||n.salesReports;return(0,D.jsxs)(o.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,D.jsx)(A,{example:i.example}),_?(0,D.jsxs)(B,{testID:"insights-group-superpro",title:P,sub:"Connected EPOS insights",children:[n.sales?(0,D.jsx)(R,{plan:I('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>c('insights-sales'),big:C(u.last7),line:null==u.last7?u.missing7?`Not enough data: ${u.missing7} cash up${1===u.missing7?'':'s'} in the last 7 days ha${1===u.missing7?'s':'ve'} no card or cash total`:'No signed-off cash ups in the last 7 days':`Last 7 days, card + cash \u2212 card tips from ${u.days7}${u.missing7?` of ${u.days7+u.missing7}`:''} cash-up day${u.days7+u.missing7===1?'':'s'}${u.missing7?` (${u.missing7} with no card or cash total)`:''}${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)}`:u.missing7?'Not enough data, the cash ups have no card or cash total':'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,D.jsx)(O,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,n.stock?(0,D.jsx)(R,{plan:I('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>c('insights-stock'),tone:h.low.length?k.colours.amber:void 0,big:h.low.length?`${h.low.length} low`:h.tracked?'None low':'\u2014',line:`${h.low.length?h.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):h.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${h.rises.length} price rise${1===h.rises.length?'':'s'} in ${w.RISE_DAYS} days`,a11y:`Stock. ${h.low.length} tracked items low or out. ${h.rises.length} price rises in ${w.RISE_DAYS} days`}):null,n.gp?(0,D.jsx)(R,{plan:I('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>c('insights-gp'),tone:g.drops.length?k.colours.amber:void 0,big:null==g.menu?'\u2014':L(g.menu),line:null==g.menu?`Not enough data: ${g.fullyCosted} of ${g.costed} costed dishes have every ingredient costed`:`Menu GP, ${g.fullyCosted} fully costed dishes${null!=g.startMenu?` \xb7 ${G(g.menu-g.startMenu)} pts in 3 months`:''} \xb7 ${g.drops.length} dish${1===g.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(g.menu)}. ${g.drops.length} dishes fell after a cost change`,children:(0,D.jsx)(O,{testID:"insight-gp-spark",values:g.trend.map(e=>e.menu)})}):null,n.clock?(0,D.jsx)(R,{plan:I('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>c('insights-clock'),tone:a.unsigned?k.colours.amber:void 0,big:String(a.total),line:`Edits in ${w.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 ${w.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,D.jsxs)(B,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[n.salesReports?(0,D.jsx)(R,{plan:I('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:C(v.gross),line:v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}${v.top.length?` \xb7 ${v.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}, ${C(v.gross)}`:'None yet')}):null,n.bookings?(0,D.jsx)(R,{plan:I('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,n.noshows?(0,D.jsx)(R,{plan:I('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?k.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}${n.sales?` (${(0,$.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,n.orders?(0,D.jsx)(R,{plan:I('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,$.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,n.reviews?(0,D.jsx)(R,{plan:I('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:y.low30?k.colours.amber:void 0,big:null!=y.avg30?`${y.avg30.toFixed(1)} \u2605`:'\u2014',line:`${y.count30} review${1===y.count30?'':'s'} in 30 days \xb7 ${y.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${y.avg30??'none'} stars from ${y.count30} reviews in 30 days`}):null,n.loyalty?(0,D.jsx)(R,{plan:I('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:d.big,line:d.line,a11y:`Loyalty. ${l?.members??'Not known'} members. ${l?.stampsMonth??'Not known'} stamps this month. ${l?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,n.labour?(0,D.jsx)(R,{plan:I('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=b.pct7&&b.pct7>35?k.colours.amber:void 0,big:null!=b.pct7?`${b.pct7}%`:'\u2014',line:null!=b.pct7?`Wages of takings on the ${b.days7} day${1===b.days7?'':'s'} with takings, last 7 days \xb7 ${C(b.labour7)} wages`:`Not enough data: no day in the last 7 has both signed-off hours and takings \xb7 ${b.paidHours7} signed-off hours`,a11y:`Wages and hours versus takings. ${b.pct7??'Not known'} percent over 7 days, ${b.paidHours7} hours`}):null]}):null]})}function E(){return(0,D.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function W({a:e,b:s,tone:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]})}},1466,[1467,17,385,85,780,777,858,1243,1008,905,876,895,897,864,1146,851,1468,1470,899,804,1057,1180,1471,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"coverOverridesFrom",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"coverOverridesFor",{enumerable:!0,get:function(){return c}});var o=r(_d[0]);const t={anchorage:{'2026-11-09':{covers:50,why:'BBC function, prepaid, 50 people (Gordon, 25 Nov 2026)'}}},n=(o,n)=>n?Object.fromEntries(Object.entries(t[o]??{}).map(([o,t])=>[o,t.covers])):{},c=t=>n(t,o.LIVE_VENUE_BUILD)},1467,[822]); +__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=l,_e.previousRange=function(e,n){const o=l(e,n);if('today'===n||'week'===n)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===n?1:0)-('today'===n?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===n?1:0)-('today'===n?1:0))};const[r,s]=o.from.split('-').map(Number),u=`${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=`${u.slice(0,7)}-${o.to.slice(8,10)}`;return{from:u,to:d<=c&&d>=u?d:c}},_e.changePct=function(t,e){return null==t||null==e||0===e?null:Math.round((t-e)/e*1e3)/10},_e.changeWords=function(t,e){if(null==t)return null;const n='today'===e?'yesterday':'week'===e?'last week':'last month';return 0===t?`No change vs ${n}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${n}`},_e.canSeeTakingsStats=function(t,e,n){return!('owner'!==t&&'manager'!==t||e&&!n)},_e.coversInRange=function(t,e){let s=0,l=0;for(const u of t){if(!u.date||!n(u.date,e))continue;if(!r(u.status))continue;const t=u.partySize||0;o(u)?s+=t:l+=t}const u=s+l;if(!u)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/u*100);return{total:u,walkIns:s,bookings:l,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,e,r){const l=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t)&&(s(t.status)||'noshow'===t.status));if(!l.length)return{rate:null,count:0,of:0,empty:!0};const u=l.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/l.length*1e3)/10,count:u,of:l.length,empty:!1}},_e.cancelRate=function(t,e,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const l=s.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(l/s.length*1e3)/10,count:l,of:s.length,empty:!1}},_e.takingsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{gross:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{gross:null,days:0,missing:u.length,missingDates:u}},_e.grossDays=u,_e.tipsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.combinedTips)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{tips:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{tips:null,days:0,missing:u.length,missingDates:u}},Object.defineProperty(_e,"completeTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"missingWords",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"takingsMissingWords",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return g}}),_e.tipsVsTakings=function(e,o,r){let s=0,l=0,u=0;for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals),d=(0,t.combinedTips)(c.vals);null==e||null==d||e<=0||(s+=d,l+=e,u+=1)}return u?{pct:g(Math.round(100*s)/100,Math.round(100*l)/100),days:u}:{pct:null,days:0}},_e.spendPerHeadInRange=function(t,n,o,r,s={}){const l=[...u(t,o,r).entries()].map(([t,r])=>({date:t,gross:r,covers:(0,e.coversOn)(n,o,t)+(s[t]??0)})),c=l.filter(t=>t.covers>0),d=l.length-c.length;if(!c.length)return{sph:null,covers:0,gross:null,days:0,noCovers:d};const f=Math.round(100*c.reduce((t,e)=>t+e.gross,0))/100,g=c.reduce((t,e)=>t+e.covers,0);return{sph:Math.round(f/g*100)/100,covers:g,gross:f,days:c.length,noCovers:d}},_e.labourCostInRange=h,_e.labourVsTakings=function(t,e,n,o,r){const s=u(n,o,r),l=s.size?Math.round(100*[...s.values()].reduce((t,e)=>t+e,0))/100:null,c=s.size?h(t,r,s):null;return{pct:m(c,l),labour:c,gross:l,days:s.size,awaiting:e.filter(t=>s.has(t)).length,labourAll:h(t,r)}},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return m}}),_e.repeatGuestPct=function(t,e,o){const r=new Set;for(const n of t){if(o&&n.restaurantId!==o)continue;if(!s(n.status)||n.date>=e.from)continue;const t=p(n);t&&r.add(t)}const l=new Set;let u=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!n(d.date,e))continue;const t=p(d);t&&!l.has(t)&&(l.add(t),u+=1,r.has(t)&&(c+=1))}return u?{rate:Math.round(c/u*1e3)/10,count:c,of:u,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.firstVisitDate=function(t,e){let n=null;for(const o of t)e&&o.restaurantId!==e||!s(o.status)||!o.date||(!n||o.date(null==t.status||'published'===t.status)&&n(t.createdAt.slice(0,10),e)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,e)=>t+e.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"NOT_SHOWN_YET",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return e.coversOn}});var t=_r(_d[0]),e=_r(_d[1]);const n=(t,e)=>t>=e.from&&t<=e.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function l(e,n){return'today'===n?{from:e,to:e}:'week'===n?{from:(0,t.weekStartOf)(e),to:e}:{from:`${e.slice(0,7)}-01`,to:e}}function u(e,o,r){const s=new Map;for(const l of e){if(l.rid!==o||!l.confirmedAt||!n(l.date,r))continue;const e=(0,t.tillTakingsOf)(l.vals);null!=e&&s.set(l.date,e)}return s}const c=(t,e)=>t.missing?null:e,d=(t,e,n)=>`Not enough data: ${t} cash up${1===t?' has':'s have'} no ${e} yet (${n.map(v).join(', ')})`,f=t=>`${t.length} cash up${1===t.length?' has':'s have'} no card or cash total yet (${t.map(v).join(', ')}), so ${1===t.length?'it is':'they are'} not in the total`,g=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function h(t,e,o){let r=0,s=!1;for(const l of t)!n(l.date,e)||l.ratePence<=0||l.paidMins<=0||o&&!o.has(l.date)||(r+=l.paidMins/60*l.ratePence,s=!0);return s?Math.round(r)/100:null}const m=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function p(t){const e=(t.phone||'').replace(/\s+/g,'').toLowerCase(),n=(t.email||'').trim().toLowerCase();return e.length>=7?`p:${e}`:n.includes('@')?`e:${n}`:null}const y='Not shown yet: GP and food cost %, table occupancy and top dishes. They need till sales, which CoverCharge does not have yet.',b={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.'},k=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,v=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,w=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1468,[839,1469]); +__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,u={}){const l=(0,r.weekStartOf)(o);return Array.from({length:d},(f,h)=>{const m=(0,r.addDaysYmd)(l,7*(h-d+1)),p=i(n,t,s,(0,r.addDaysYmd)(m,6),7,u).filter(r=>r.date<=o&&null!=r.gross),v=p.length?Math.round(100*p.reduce((r,n)=>r+n.gross,0))/100:null,y=p.reduce((r,n)=>r+n.covers,0);return{weekStart:m,gross:v,covers:y,days:p.length,sph:c(v,y)}})},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,l={}){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,h)=>{const m=(0,r.addDaysYmd)(o,h-i+1),p=f.get(m)?.vals??{},v=(0,r.tillTakingsOf)(p),y=d(t,s,m)+(l[m]??0),b=u(p.food),k=u(p.drink);return{date:m,gross:v,covers:y,sph:c(v,y),food:b,drink:k,foodPh:c(b,y),drinkPh:c(k,y)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.tillTakingsOf)(n.vals))},1469,[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=d,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return c}}),_e.salesInsight=function(e,t,r,o,s={}){const a={from:d(o,-6),to:o},i={from:d(o,-13),to:d(o,-7)},l=(0,n.takingsInRange)(e,r,a),c=(0,n.takingsInRange)(e,r,i),u=(0,n.spendPerHeadInRange)(e,t,r,a,s),f=u.sph,g=[];for(let t=7;t>=0;t--){const s=d(o,-7*t),a=d(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});g.push({from:a,to:s,gross:i.gross,days:i.days,missing:i.missing})}const p=null!=l.gross&&null!=c.gross&&c.gross>0&&!l.missing&&!c.missing?Math.round((l.gross-c.gross)/c.gross*1e3)/10:null;return{last7:l.gross,prev7:c.gross,changePct:p,days7:l.days,missing7:l.missing,sphDays7:u.days,sph7:f,weeks:g,empty:g.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=d(s,-30),c=[];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&&c.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})}c.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:c,lastCount:u?.date??null,empty:!a.length&&!c.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"MIN_FULLY_COSTED",{enumerable:!0,get:function(){return g}}),_e.fullyCostedIds=p,_e.gpInsight=function(n,r,o,s,a,i){const l=p(n,r,o,s),c=o.filter(e=>(r[e.id]?.lines?.length??0)>0).length;if(l.sizel.has(e.id)),f=(0,e.menuGp)(n,r,u,s),m=(0,e.gpHistory)(a,f,'3m',i),h=m.points.find(e=>null!=e.menu)?.menu??null,b=f.dishes.map(e=>{const t=m.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)),k=(0,t.marginDrops)(a,d(i,-14)).filter(e=>u.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{fullyCosted:l.size,costed:c,menu:f.menu,startMenu:h,trend:m.points.map(e=>({week:e.week,menu:e.menu})),dishes:b,drops:k,underTarget:f.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?b(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return y(n)},_e.clockChangesFromServer=function(e){return y(e.filter(e=>h.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:k(e.action,e.old_value),after:k(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 w}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:d(r,-6),to:r},a={from:d(r,-13),to:d(r,-7)},i={from:d(r,-29),to:r},l=(0,n.coversInRange)(o,s),c=(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:c.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=d(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:d(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,o,s=[]){const a={from:d(o,-6),to:o},i=(0,n.labourVsTakings)(e,s,t,r,a),l=e.filter(e=>e.date>=a.from&&e.date<=a.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:i.labour,takings7:i.gross,pct7:i.pct,days7:i.days,paidHours7:Math.round(l/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=v(e.members),r=v(e.stampsMonth),o=v(e.rewardsUsedMonth??e.rewardsMonth),s=v(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 d(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 c=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14,g=5;function p(e,n,r,o){const s=new Set;for(const a of r){const r=n[a.id];if(!r||!r.lines?.length)continue;if(null==a.ingCount||r.lines.length0||i.priceIsSuggested||s.add(a.id)}return s}const m={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'},h=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),b=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 k(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:b(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const y=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const w=30;const v=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1470,[908,906,1468]); +__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},1471,[]); +__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.useAssistantRequestInbox=x,_e.AssistantRequestsButton=function({go:e,testID:t}){const{visible:s,count:l}=x();return s?(0,b.jsx)(n.default,{style:{width:'100%',maxWidth:900,alignSelf:'center',paddingHorizontal:14,paddingTop:4,paddingBottom:8},children:(0,b.jsx)(o.Button,{testID:t??'assistant-requests-btn',label:l?`Assistant requests \xb7 ${l}`:'Assistant requests',accessibilityLabel:(0,p.assistantRequestsButtonLabel)(l),accessibilityHint:"Opens the list of changes your assistant has asked you to confirm or decline",kind:l?'primary':'secondary',onPress:()=>e('more','assistant-requests'),style:{minHeight:56}})}):null},_e.AssistantRequestsPage=function(){const{rows:e,load:t,visible:s}=x();if(!s)return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner can confirm or decline assistant changes, and only when an assistant is paired."})]});return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{gap:12,paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Each change waits for an owner to approve or decline it. Important changes ask a second time."}),(0,b.jsx)(w,{rows:e,onChanged:()=>{t()}})]})},_e.AssistantPendingCard=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(null),c=async()=>{try{r(await(0,l.assistantProposalsList)())}catch{r([])}};return(0,t.useEffect)(()=>{if(!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR)return;c();const t=setInterval(()=>{c()},2e4);return()=>clearInterval(t)},[e,s,n]),!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR?null:(0,b.jsx)(w,{rows:o,onChanged:()=>{c()},compact:!0})},_e.AssistantsPage=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),[s,r]=(0,t.useState)(''),[u,h]=(0,t.useState)(null),[p,x]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[A,I]=(0,t.useState)(null),[k,D]=(0,t.useState)(null),[C,S]=(0,t.useState)(null),[T,P]=(0,t.useState)(null),L=async()=>{try{P(await(0,l.assistantAccess)())}catch{P({plan:null,allowed:!1,reason:'Could not check this plan.'})}try{v(await(0,l.assistantList)())}catch{v([])}try{I(await(0,l.assistantProposalsList)())}catch{I([])}try{D(await(0,l.assistantAuditList)())}catch{D([])}};(0,t.useEffect)(()=>{e&&L()},[e]);const R=s.replace(/\D/g,''),$=!!T?.allowed,M=async()=>{x(!0),h(null);const e=await(0,l.assistantApprove)(R);x(!1),e.ok?(r(''),h({ok:!0,text:'Done. The assistant is paired. It can look things up and propose changes, which wait for an owner to confirm on their phone.'}),L()):h({ok:!1,text:e.message})},q=async(e,t)=>{x(!0),h(null);const s=await(0,l.assistantSetEnabled)(e.id,t);x(!1),s.ok?(h({ok:!0,text:t?`${e.label} is switched on.`:`${e.label} is switched off. It stays paired, and you can switch it on again.`}),L()):h({ok:!1,text:s.message})};return(0,b.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,b.jsx)(w,{rows:A,onChanged:()=>{L()}}):null,(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair your assistant"}),(0,b.jsx)(o.T,{center:!0,children:f}),(0,b.jsx)(o.T,{center:!0,children:"Ask your assistant, such as Grok Bot, to start CoverCharge sign-in. It will show 6 numbers. Only an owner of this venue can approve it. In the connected assistant it can answer questions about your venue and give advice from the data it is allowed to look up. It can propose a change; nothing is changed until an owner confirms it on their 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 a second time, with a plain warning of what is affected."}),!$&&T?(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-plan-blocked",children:T.reason||'Connecting an AI assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.'}):null,(0,b.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:s,onChangeText:e=>r(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,b.jsx)(o.Button,{testID:"assistant-approve",label:p?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs your AI assistant with this venue",disabled:!e||!$||p||6!==R.length,onPress:()=>{M()},style:{minHeight:56}}),e?null:(0,b.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,b.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!u,accessibilityLabel:u?.text,children:u?(0,b.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:u.ok?c.colours.goldLight:c.colours.amber,children:u.text}):null}),(0,b.jsx)(o.Muted,{center:!0,children:"Never send a personal app link to the bot. That link stays on your phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, it cannot read other venues, and it cannot change its own access or pairing."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(t=>(0,b.jsxs)(n.default,{testID:`assistant-row-${t.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:`${t.label} \xb7 ${!1===t.enabled?'switched off':'paired'}`}),(0,b.jsx)(o.Muted,{center:!0,children:`Since ${y(t.approvedAt)}. Last seen ${y(t.lastSeenAt)}.${t.ownerName?` Tied to ${t.ownerName}.`:''}`}),(0,b.jsx)(o.Toggle,{testID:`assistant-enabled-${t.id}`,label:"Assistant on",value:!1!==t.enabled,disabled:p||!e,onChange:e=>{q(t,e)},a11y:!1===t.enabled?`Switch on ${t.label}`:`Switch off ${t.label}`}),(0,b.jsx)(o.Button,{testID:`assistant-revoke-${t.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${t.label}`,onPress:()=>S(t),style:{minHeight:56}})]},t.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Activity log"}),(0,b.jsx)(o.Muted,{center:!0,children:"Everything this venue\u2019s assistants do is logged here, including look-ups. The assistant cannot change or skip this log."}),null===k?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):k.length?k.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-audit-${e.id}`,style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:e.detail||e.action}),(0,b.jsx)(o.Muted,{center:!0,children:`${y(e.at)}${e.actorName?` \xb7 ${e.actorName}`:''}`})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-audit-empty",children:"No activity yet."})]}),C?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>S(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,b.jsx)(o.T,{center:!0,children:`${C.label} stops working straight away. Any changes still waiting are cancelled. Your phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,b.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=C;S(null);const t=await(0,l.assistantRevoke)(e.id);h(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),L()},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>S(null),style:{minHeight:56}})]}):null]})};var t=_r(d[0]),s=e(_r(d[1])),n=e(_r(d[2])),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]);const y=e=>e?`${(0,r.niceDate)(new Date(e))} at ${(0,r.hm)(new Date(e))}`:'not yet',f='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.';function w({rows:e,onChanged:r,compact:u}){const h=(e??[]).filter(e=>'pending'===e.status),[f,w]=(0,t.useState)(null),[x,j]=(0,t.useState)(null),[v,A]=(0,t.useState)(null),I=async(e,t,n=!1)=>{w(e.id),j(null);const o=await(0,l.assistantProposalDecide)(e.id,t,n);if(w(null),o.ok){A(null);const e='decline'===t?'Declined. Nothing was changed.':'Done. The change has been made.';j(e),s.default.announceForAccessibility(e),r?.()}else j(o.message),s.default.announceForAccessibility(o.message)};return!h.length&&u?null:(0,b.jsx)(n.default,{testID:u?'assistant-pending-home':'assistant-pending-list',children:(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Waiting for an owner to confirm"}),e?h.length?h.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:8,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,alignItems:'center'},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,b.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${y(e.expiresAt)}.`:'']}):e.expiresAt?(0,b.jsx)(o.Muted,{center:!0,children:`Runs out at ${y(e.expiresAt)}.`}):null,e.canDecide?(0,b.jsxs)(n.default,{style:{gap:8,width:'100%',maxWidth:520,alignSelf:'center'},children:[(0,b.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:f===e.id?'Working\u2026':'Approve',accessibilityLabel:(0,p.assistantRequestActionLabel)('Approve',e.summary),accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!f,onPress:()=>{e.needsDoubleConfirm?A(e):I(e,'approve')},style:{minHeight:56}}),(0,b.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",accessibilityLabel:(0,p.assistantRequestActionLabel)('Decline',e.summary),disabled:!!f,onPress:()=>{I(e,'decline')},style:{minHeight:56}})]}):(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner of this venue can confirm or decline this on their phone."})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,b.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),(0,b.jsx)(n.default,{accessible:!0,accessibilityLiveRegion:"polite",accessibilityRole:"text",testID:"assistant-requests-status",style:{minHeight:x?void 0:0},children:x?(0,b.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:x}):null}),v?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>A(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,b.jsx)(o.T,{center:!0,accessibilityRole:"header",children:v.summary}),(0,b.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."}),v.warning?(0,b.jsx)(o.Muted,{center:!0,children:v.warning}):null,(0,b.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:f===v.id?'Working\u2026':'Yes, make this change',disabled:!!f,accessibilityLabel:`Yes, make this change: ${v.summary}`,onPress:()=>{I(v,'approve',!0)},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Go back",accessibilityLabel:`Go back without changing: ${v.summary}`,onPress:()=>A(null),style:{minHeight:56}})]}):null]})})}function x(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(0),[c,b]=(0,t.useState)(null),y=async()=>{try{const[e,t]=await Promise.all([(0,l.assistantList)(),(0,l.assistantProposalsList)()]);r((e??[]).length),b(t??[])}catch{r(0),b([])}};(0,t.useEffect)(()=>{if('owner'!==u.APP_VARIANT||u.IS_CAR||n||'owner'!==s||!e)return;y();const t=setInterval(()=>{y()},2e4);return()=>clearInterval(t)},[e,s,n]);const f=(c??[]).filter(e=>'pending'===e.status).length;return{visible:(0,p.canSeeAssistantRequests)({appVariant:u.APP_VARIANT,isCar:u.IS_CAR,inStaffApp:n,role:s,live:e,pairedCount:o}),count:f,rows:c,load:y,paired:o}}},1472,[17,264,85,777,899,863,804,856,1057,1473,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.assistantRequestActionLabel=function(t,s){const n=String(s||'this change').replace(/\s+/g,' ').trim().replace(/\.+$/,'');return`${t}: ${n||'this change'}`},e.assistantRequestsButtonLabel=function(t){const s=Math.max(0,Math.floor(Number(t)||0));return 1===s?'Assistant requests, 1 waiting':`Assistant requests, ${s} waiting`},e.canSeeAssistantRequests=function(t){return'owner'===t.appVariant&&!t.isCar&&!t.inStaffApp&&'owner'===t.role&&!!t.live&&(t.pairedCount??0)>0}},1473,[]); +__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"})]})}},1474,[817,1190,17,264,266,347,378,219,278,85,19,777,857,860,876,998,1036,1037,805,842,1034,1475,804,856,1057,1476,1479,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}}},1475,[1034]); +__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=C,_e.importQuestionnaireAccounts=B,_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. 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)(i.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:l}=(0,x.useCtx)(6e4),j='owner'===n,I=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],M=(0,p.useQuestionnaire)(e),{mark:P}=(0,p.useProvenance)(e),[A,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(M?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!I.some(n=>n.provider===e.provider)),[M,I]),W=(M?.accounts??[]).some((e,n)=>P('accounts',n,'provider'));return(0,y.jsxs)(i.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)(i.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:P('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:l})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>M&&B(e,M,l)}):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:`${I.length}`})]}),I.length?I.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(M?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(i.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)(i.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:P('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:T[e.status].kind,label:T[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)(C,{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=I.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:A,owner:j,by:l,onClose:()=>z(null)}),$?(0,y.jsx)(k,{rid:e,c:$,by:l,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),l=e(r(d[4])),i=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)(i.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 C({rid:e,compact:n}){const{role:o,me:l}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,C]=(0,t.useState)({}),[B,I]=(0,t.useState)(null),T=u.useAccounts.getState();return(0,y.jsxs)(i.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)(i.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)(i.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)(i.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)(i.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>C({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(i.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:()=>T.update(e,o.id,{accountNo:u},l,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>I(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>T.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:l})})}),(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)}),B?(0,y.jsx)(k,{rid:e,c:B,by:l,onClose:()=>I(null)}):null]})}function k({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)(i.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:["CoverCharge will stop listing ",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 B(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const l of n.accounts??[])o.some(e=>e.provider===l.provider)||s.add(e,{provider:l.provider,handle:l.handle,status:'listed',from:'questionnaire',addedBy:t})}function I({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,C]=(0,t.useState)(p?.handle??''),[k,B]=(0,t.useState)(p?.customName??''),[I,T]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const M=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${M?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(l.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(i.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:M?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),M?(0,y.jsx)(a.Field,{label:"Service name",value:k,onChangeText:B,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:()=>T(!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."]})]}),I?(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, 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:C,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:M?'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:M&&k.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:M?k.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:M&&!k.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)(i.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)(i.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)(i.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 T={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)(I,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1476,[812,17,362,385,278,85,777,1477,1478,804,1474,1057,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)},1477,[]); +__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)}))},1478,[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})]})}},1479,[17,385,85,777,860,1478,998,842,1480,1475,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'},1480,[]); +__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}},1481,[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])},1482,[1185,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1182,1445,1162,860,1186,853,1184,884,1361,998,843,1115,1199,1206,1071,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']}},1483,[17,1055,85,409,777,858,1141,1140,861,863,804,876,1184,1057,1149,1145,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}))},1484,[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]})]})}},1485,[805,1420,843,1394,17,85,777,858,860,866,845,851,1160,1105,863,804,1184,1057,1161,1162,853,1426,848,900,1486,8]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const a=!!e.settings.takeawayPaused;return(0,u.jsx)(l.Card,{highlight:a?r.colours.red:void 0,children:(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(l.T,{weight:"semibold",children:a?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,u.jsx)(l.Muted,{children:a?'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,u.jsx)(l.Toggle,{testID:"takeaway-pause",label:a?'Resume':'Pause',value:!a,onChange:a=>t.useStore.getState().updateSettings(e.id,{takeawayPaused:!a})})]})})},_e.TakeawayMenuList=function({me:e}){const[s,t]=(0,a.useState)(!1),c=(0,o.useStaffTakeaway)(e=>e.rows),h=(0,o.useStaffTakeaway)(e=>e.canSet),f=(0,o.useStaffTakeaway)(e=>e.busy),w=(0,o.useStaffTakeaway)(e=>e.error),y=(0,o.useStaffTakeaway)(e=>e.loadedAt);(0,a.useEffect)(()=>{s&&(0,o.loadStaffTakeaway)(!0)},[s]);const k=c?Object.values(c).sort((e,a)=>e.section.localeCompare(a.section)||e.dish.localeCompare(a.dish)):null,j=k?.filter(e=>e.onMenu).length??0,x=y>0&&null===c;return(0,u.jsxs)(l.Card,{children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",k?` \xb7 ${j} of ${k.length} available`:'']}),(0,u.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Hide':'Choose dishes',onPress:()=>t(!s),testID:"takeaway-menu"})]}),s?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(l.Muted,{children:"The whole menu shows on the takeaway page. Switch off what can\u2019t be done for takeaway today: guests see it as \u201cNot available for takeaway today\u201d. A dish also needs Head Chef allergen sign-off and a price."}),!h&&k?(0,u.jsx)(l.Muted,{children:"Only the Head Chef, a manager or an owner can change this."}):null,x?(0,u.jsx)(l.Banner,{kind:"warn",children:"Connect to the venue to see the takeaway menu."}):null,w?(0,u.jsx)(l.Banner,{kind:"warn",children:w}):null,k||x||w?null:(0,u.jsx)(l.Muted,{children:"Loading\u2026"}),(k??[]).map(a=>(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsxs)(l.T,{size:14,children:[a.dish,a.pricePence?` \xb7 ${(0,d.gbp)(a.pricePence)}`:'']}),(0,u.jsxs)(l.Row,{gap:4,children:['Specials board'===a.section?(0,u.jsx)(l.Badge,{kind:"gold",label:"Special"}):null,a.soldOut?(0,u.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,a.signedOff?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),a.pricePence?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),h?(0,u.jsx)(l.Toggle,{label:"Available for takeaway",a11y:`Available for takeaway, ${a.dish}`,value:a.onMenu,disabled:f===a.itemId,onChange:s=>{(0,o.setTakeawayAvailable)(a.itemId,s,e).catch(()=>{})}}):(0,u.jsx)(l.T,{size:14,colour:a.onMenu?r.colours.gold:r.colours.muted,children:a.onMenu?'Available':'Not today'})]},a.itemId))]}):null]})};var e,a=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),t=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),u=_r(_d[7])},1486,[17,85,777,858,851,1159,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 Ce}});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]),w=_r(d[16]),v=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),I=_r(d[22]),M=_r(d[23]),G=_r(d[24]),O=_r(d[25]),E=_r(d[26]),B=_r(d[27]),x=_r(d[28]),D=_r(d[29]),N=_r(d[30]),L=(e=N)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),q=_r(d[33]),Q=_r(d[34]),F=_r(d[35]),U=_r(d[36]),V=_r(d[37]),W=_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]),ye=_r(d[64]);const Ce=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},me=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:me,C:v.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=>me(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:me,C:O.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:me,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=>me(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:me,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:me,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:me,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:me,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:me,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:me,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:me,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:E.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:me,C:G.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:me,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:B.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:B.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:me,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:me,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:me,C:w.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:B.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:B.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:B.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:me,C:B.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:me,C:B.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:me,C:B.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:me,C:B.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:me,C:B.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:B.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:me,C:B.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:B.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:()=>Ce(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:me,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:me,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:me,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:me,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:me,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:me,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const Se=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(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:Se,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:Se,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:me,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:me,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:me,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:me,C:F.DisplaySettingsPage}]);const ke=e=>'owner'===e||'manager'===e;U.ASSISTANT_AVAILABLE&&V.ASSISTANT_UI&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:ke,C:U.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:ke,C:U.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:Y.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair your own AI assistant with a 6-digit code, switch it off, or unpair it',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantsPage}]),(0,y.register)([{id:'assistant-requests',title:'Assistant requests',sub:'Confirm or decline changes your assistant has proposed',group:'Start here',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantRequestsPage}]);const we=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:I.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:I.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:I.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:I.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:I.InsightsClockPage}]);const Pe=()=>{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)},Re=e=>we(e)&&Pe();(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:we,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:Re,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:Re,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:Re,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:we,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,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:we,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:me,C:z.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:me,C:z.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:me,C:z.Outbox}]);const Ae=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:Ae,C:J.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:J.optinsAllowed,C:J.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Ae,C:$.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Ae,C:K.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:Ae,C:X.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:Ae,C:Z.OrderSheetSettings},...ee.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Ae,C:(0,K.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Ae,C:te.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Ae,C:se.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:me,C:se.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Ae,C:se.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:Ae,C:ae.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:me,C:ie.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:me,C:ie.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:me,C:ie.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:me,C:re.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos and Show me where',group:'Start here',can:me,C:oe.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:me,C:ue.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:me,C:le.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:le.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ce.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ge.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:we,C:function(){const{rid:e,today:t}=(0,de.useCtx)(6e4);return L.default.createElement(ge.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(pe.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:me,C:ne.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(he.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:me,C:be.NightlyReportPage}]),(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:ye.UseOnComputerPage}]),(0,y.register)([{id:'support',title:'Customer support',sub:'Send a message or a picture to CoverCharge',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:fe.SupportChatPage}])},1487,[822,1050,856,1488,876,920,909,816,866,1490,1497,1499,1458,1500,1501,1503,1504,1161,1483,1505,1506,1507,1466,1202,1193,1485,1508,1456,1509,1510,17,1199,1182,1457,1445,1459,1515,1214,1521,1522,1472,1523,1448,1433,1524,1463,1525,886,1526,1527,1529,1188,1474,1530,1394,1476,1542,1081,1057,1203,1153,1546,1549,1552,1554]); +__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)}},1488,[17,378,219,385,85,19,777,1026,1340,876,804,1489,1190,1484,1057,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}))},1489,[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}},1490,[812,1454,17,851,85,777,876,804,1057,884,885,1491,899,916,1031,1452,1492,1493,1495,996,1496,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},1491,[]); +__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])},1492,[812,17,85,777,804,876,1356,1355,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])},1493,[17,85,777,1494,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},1494,[831,928,899,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]},1495,[17,85,777,804,914,1022,899,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])},1496,[928,899]); +__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 h}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LINE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LITE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_TERM",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return C}}),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 U}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return $}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),h=(0,u.trialStatus)((0,l.defaultSimStart)(),e),[y,f]=(0,t.useState)(!1);return i.CAN.billing(n)?y?(0,p.jsx)(q,{onBack:()=>f(!1)}):(0,p.jsxs)(o.default,{style:{gap:10},children:[(0,p.jsx)(s.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,p.jsxs)(s.Card,{highlight:d.colours.gold,children:[(0,p.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,p.jsxs)(s.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[S,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-early-term",children:D})]}),(0,p.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:Y.map(([e,t])=>(0,p.jsxs)(o.default,{testID:e===b?'plan-early-guest-app':e===x?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,p.jsxs)(s.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,p.jsx)(s.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,p.jsx)(s.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,N,M,z,'Usual price',''],['plan-usual-pro',E,R,U,G,'Usual price',''],['plan-superpro',k,C,F,V,'1-year contract','No hardware included.']].map(([e,t,n,l,i,u,c])=>(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,p.jsxs)(s.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsx)(s.Muted,{center:!0,children:S}),(0,p.jsx)(s.Muted,{center:!0,children:l}),'plan-superpro'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-superpro-epos-line",children:B}):null,i.map(e=>(0,p.jsxs)(s.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),'plan-usual-lite'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-lite-ai",children:I}):null,c?(0,p.jsx)(s.Muted,{center:!0,children:c}):null]})},e)),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-terms",children:$}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>f(!0),style:{alignSelf:'center'}}),(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,p.jsxs)(s.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,p.jsx)(s.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,p.jsx)(s.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,p.jsx)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{children:"Free trial"}),(0,p.jsxs)(s.T,{weight:"bold",colour:d.colours.gold,children:[h.daysLeft," day",1===h.daysLeft?'':'s'," left"]})]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-h.daysLeft/h.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,p.jsxs)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'center'},gap:8,children:[(0,p.jsx)(s.T,{weight:"semibold",children:"Free customer support"}),(0,p.jsx)(s.Badge,{kind:"gold",label:"Included"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,p.jsx)(s.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},s=r(_d[2]),l=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]);const h=!0,y='Early adopter offer, usual prices, free trial, set-up guide',f='. 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',b='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',j='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',x='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.',_='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',v='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',I='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer.',O='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',S='+ VAT if applicable, per venue',L='Customer & Takeaway App',E='Full Restaurant Pro App',k='SuperPro',N='\xa349',R='\xa399',C='\xa3149',M='The lite version: core features for smaller venues.',U='Every feature, every app.',F='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',B='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.',D='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.',Y=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',D],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[b,A],['Free customer support','For the length of your subscription.'],[x,T],[v,v],[j,w]],z=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',b,P,j],G=['Owner dashboard and admin','Supplier links',x,v,b,P,j],V=['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',_,v,b,P,j],$='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. AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',K=[['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 q({onBack:e}){const[n,l]=(0,t.useState)([]);return(0,p.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,p.jsx)(s.H2,{children:"Set-up guide"}),(0,p.jsxs)(s.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",K.length," done."]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/K.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),K.map(([e,t],i)=>{const u=n.includes(i);return(0,p.jsx)(s.Card,{children:(0,p.jsxs)(s.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.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,p.jsx)(s.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,p.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(s.T,{weight:"semibold",children:e}),(0,p.jsx)(s.Muted,{children:t}),(0,p.jsx)(s.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>l(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,p.jsx)(s.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1497,[17,85,777,835,876,1498,804,1057,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'}},1498,[]); +__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]})]})]})}},1499,[805,1033,891,1420,813,812,822,1263,1440,17,385,393,85,864,777,858,876,845,851,863,804,1184,1057,1161,1445,1221,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])},1500,[843,17,85,1162,777,858,845,853,863,804,1184,1057,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])},1501,[1039,17,85,1502,814,857,777,876,804,1057,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}})},1502,[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])},1503,[17,1155,847,1057,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])},1504,[17,1032,1057,899,915,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])},1505,[17,1400,1057,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=b,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,u.useCtx)(6e4),n=(0,o.useBookings)(e),i=(0,d.useCashUp)(e=>e.cashUps),[j,w]=(0,s.useState)('day'),f=(0,h.hasAnyTakings)(i,e),k=(0,l.coverOverridesFor)(e),v=(0,h.dayRows)(i,n,e,t,14,k),$=(0,h.weekRows)(i,n,e,t,8,k),T=(0,h.averageSph)(v),S=(e,s,t,l,n)=>(0,p.jsxs)(a.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:c.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===l?'no takings entered':`spend per head ${l}`}, ${t}${n?`, ${n}`:''}`,children:[(0,p.jsx)(r.T,{center:!0,children:s}),(0,p.jsx)(r.T,{center:!0,colour:c.colours.muted,children:t}),(0,p.jsx)(r.T,{center:!0,weight:"semibold",colour:'No takings entered'===l?c.colours.muted:c.colours.goldLight,size:'No takings entered'===l?13:16,children:l}),n?(0,p.jsx)(r.Muted,{center:!0,children:n}):null]},e);return(0,p.jsxs)(a.default,{style:{gap:12},testID:"sph-screen",children:[(0,p.jsx)(r.Muted,{children:"Tip: spend per head is takings \xf7 Covers. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,p.jsxs)(r.Card,{highlight:c.colours.gold,children:[(0,p.jsx)(r.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==T?(0,p.jsx)(r.T,{size:22,weight:"semibold",colour:c.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,p.jsxs)(r.T,{size:34,weight:"bold",colour:c.colours.goldLight,testID:"sph-avg",children:[x(T)," ",(0,p.jsx)(r.T,{size:16,colour:c.colours.muted,children:"per head"})]}),(0,p.jsx)(r.Muted,{children:f?'Only days with a cash up are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has card and cash totals.'})]}),(0,p.jsxs)(r.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(r.Chip,{testID:"sph-day",label:"By day",selected:'day'===j,onPress:()=>w('day')}),(0,p.jsx)(r.Chip,{testID:"sph-week",label:"By week",selected:'week'===j,onPress:()=>w('week')})]}),'day'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by day"}),(0,p.jsx)(b,{testID:"sph-trend-day",label:"Spend per head trend by day",points:v.map(e=>({label:y(e.date),value:e.sph}))}),[...v].reverse().map(e=>S(e.date,y(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':x(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${x(e.foodPh)}, drink ${x(e.drinkPh)} per head`:void 0))]}):null,'week'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,p.jsx)(b,{testID:"sph-trend-week",label:"Spend per head trend by week",points:$.map(e=>({label:`w/c ${y(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...$].reverse().map(e=>S(e.weekStart,`w/c ${y(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':x(e.sph)))]}):null,(0,p.jsx)(r.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=_r(_d[1]),a=e(_r(_d[2])),n=_r(_d[3]),i=e(n),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]);const x=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function b({points:e,testID:l,label:o}){const[d,h]=(0,s.useState)(320),[u,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,l]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,u)),w=Math.max(0,j-b),f=e.slice(w,j),k=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)),T=e=>38+e*(k-76)/Math.max(1,f.length-1),S=e=>140-e/$*106,L=[];let D=[];f.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} ${x(e.value)}`).join(', ');return(0,p.jsxs)(a.default,{testID:l,onLayout:e=>h(e.nativeEvent.layout.width),style:{gap:8},children:[(0,p.jsxs)(a.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,p.jsx)(i.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,p.jsx)(n.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:c.colours.muted,children:x($*e/4)},e))}),(0,p.jsxs)(i.default,{width:k,height:170,children:[[0,1,2,3,4].map(e=>(0,p.jsx)(n.Line,{x1:0,x2:k,y1:S($*e/4),y2:S($*e/4),stroke:c.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,p.jsx)(n.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:c.colours.gold,strokeWidth:2.5},s)),f.map((e,s)=>(0,p.jsx)(t.default.Fragment,{children:null==e.value?(0,p.jsx)(n.Circle,{cx:T(s),cy:140,r:2,fill:"#444"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.Circle,{cx:T(s),cy:S(e.value),r:4,fill:c.colours.goldLight}),(0,p.jsx)(n.Text,{x:T(s),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:c.colours.goldLight,children:x(e.value)})]})},w+s))]})]}),(0,p.jsx)(a.default,{style:{flexDirection:'row',gap:12},children:f.map((e,s)=>(0,p.jsxs)(a.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':x(e.value)}`,children:[(0,p.jsx)(r.T,{center:!0,size:12,colour:c.colours.muted,children:e.label}),(0,p.jsx)(r.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?c.colours.muted:c.colours.goldLight,children:null==e.value?'No takings entered':x(e.value)})]},w+s))}),(0,p.jsxs)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(r.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,p.jsx)(r.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))})]})]})}},1506,[17,1467,85,780,777,858,1008,1469,804,1057,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])},1507,[17,85,1349,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])},1508,[17,776,1057,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:a,role:I,today:x,signedIn:j}=(0,b.useCtx)(),[D,P]=(0,t.useState)('today'),R=(0,r.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),W=(0,c.useOwner)(e=>(0,c.liveAttendance)(e.attendance)),C=(0,b.useHourly)(),S=(0,$.useReviews)(e=>e.reviews),N=(0,u.canSeeTakingsStats)(I,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,v.ensureReviewSync)(e,'manage')},[e]);const M=(0,u.rangeFor)(x,D),L=(0,u.previousRange)(x,D),G=(0,t.useMemo)(()=>R.filter(s=>s.restaurantId===e),[R,e]),_=(0,u.coversInRange)(G,M),O=(0,u.coversInRange)(G,L),B=(0,u.noShowRate)(G,M,e),F=(0,u.noShowRate)(G,L,e),A=(0,u.cancelRate)(G,M,e),H=(0,u.cancelRate)(G,L,e),V='today'===D?(0,h.laterTodayCovers)(G,x):0,z=(0,u.takingsInRange)(T,e,M),U=(0,u.takingsInRange)(T,e,L),E=(0,s.coverOverridesFor)(e),Y=(0,u.spendPerHeadInRange)(T,G,e,M,E),q=(0,u.spendPerHeadInRange)(T,G,e,L,E),J=(0,u.tipsInRange)(T,e,M),K=(0,u.tipsInRange)(T,e,L),Q=(0,t.useMemo)(()=>W.filter(e=>'confirmed'===(0,c.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,b.paidMins)(e,a).paid,ratePence:C[e.staffId]??0})),[W,C,a]),X=(0,t.useMemo)(()=>W.filter(e=>'awaiting'===(0,c.attStatus)(e)).map(e=>e.date),[W]),Z=(0,u.labourVsTakings)(Q,X,T,e,M),ee=(0,u.labourVsTakings)(Q,X,T,e,L),se=(0,u.tipsVsTakings)(T,e,M),te=(0,u.firstVisitDate)(G,e),ae=(0,u.repeatGuestPct)(G,M,e),ne=(0,u.repeatGuestPct)(G,L,e),ie=(0,u.reviewAverage)(S.filter(s=>s.restaurantId===e),M),oe='today'===D?'today':'week'===D?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(o.T,{weight:"semibold",size:y.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(o.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)(o.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(o.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:D===e.id,onPress:()=>P(e.id)},e.id))}),(0,f.jsx)(w,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${oe}`,value:(0,u.pctLabel)(_.walkInPct),detail:_.empty?void 0:`${_.walkIns} walk-in covers \xb7 ${_.bookings} booked covers \xb7 ${_.total} total`,change:(0,u.changeWords)((0,u.changePct)(_.walkInPct,O.walkInPct),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${oe}`,value:(0,u.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(B.rate,F.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${oe}`,value:(0,u.pctLabel)(A.rate),detail:A.empty?void 0:`${A.count} cancelled out of ${A.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(A.rate,H.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-covers",label:`Covers \xb7 ${oe}`,value:_.empty?null:String(_.total),detail:_.empty?void 0:'today'===D?V>0?`${V} more ${1===V?'cover':'covers'} booked for later today`:'No more bookings for later today':`${_.walkIns} walk-in \xb7 ${_.bookings} booked`,change:(0,u.changeWords)((0,u.changePct)(_.empty?null:_.total,O.empty?null:O.total),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${oe}`,value:(0,u.pctLabel)(ae.rate),detail:ae.empty?void 0:`${ae.count} of ${ae.of} identifiable seated or finished parties had visited before${te?` (visits on record from ${(0,u.ukDay)(te)})`:''}`,change:(0,u.changeWords)((0,u.changePct)(ae.rate,ne.rate),D),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(w,{testID:"insights-reviews",label:`Reviews \xb7 ${oe}`,value:ie.empty?null:`${ie.avg} / 5`,detail:ie.empty?void 0:`Average of ${ie.count} published review${1===ie.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(w,{testID:"insights-tips",label:`Tips (team total) \xb7 ${oe}`,value:(0,u.moneyGbp)((0,u.completeTotal)(J,J.tips)),detail:null==J.tips?void 0:N&&null!=se.pct?`${J.days} cash-up day${1===J.days?'':'s'} \xb7 ${(0,u.pctLabel)(se.pct)} of takings on the ${se.days} day${1===se.days?'':'s'} with takings`:`${J.days} cash-up day${1===J.days?'':'s'}`,change:J.missing||K.missing?null:(0,u.changeWords)((0,u.changePct)(J.tips,K.tips),D),empty:J.missing?(0,u.missingWords)(J.missing,'tips figure',J.missingDates):'No tips entered in this period'}),N?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(w,{testID:"insights-takings",label:`Takings \xb7 ${oe}`,value:(0,u.moneyGbp)(z.gross),detail:null==z.gross?void 0:`Card + cash \u2212 card tips, from ${z.days}${z.missing?` of ${z.days+z.missing}`:''} confirmed cash-up day${z.days+z.missing===1?'':'s'}${z.missing?`. ${(0,u.takingsMissingWords)(z.missingDates)}`:''}`,change:z.missing||U.missing?null:(0,u.changeWords)((0,u.changePct)(z.gross,U.gross),D),empty:z.missing?(0,u.missingWords)(z.missing,'card or cash total',z.missingDates):'No takings entered in this period'}),(0,f.jsx)(w,{testID:"insights-sph",label:`Spend per head \xb7 ${oe}`,value:(0,u.moneyGbp)(Y.sph),detail:null==Y.sph?void 0:`\xa3${Y.gross.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})} takings \xf7 ${Y.covers} seated or finished covers, on ${Y.days} day${1===Y.days?'':'s'} with both${Y.noCovers?`. ${Y.noCovers} day${1===Y.noCovers?'':'s'} with takings and no Covers (a function, say) count${1===Y.noCovers?'s':''} in takings, not here`:''}`,change:(0,u.changeWords)((0,u.changePct)(Y.sph,q.sph),D),empty:Y.noCovers?'Spend per head needs a day with both takings and seated or finished Covers':'No takings entered, so no spend per head'}),(0,f.jsx)(w,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${oe}`,value:(0,u.pctLabel)(Z.pct),detail:null!=Z.pct?`${(0,u.moneyGbp)(Z.labour)} signed-off wages \xf7 ${(0,u.moneyGbp)(Z.gross)} takings, on the ${Z.days} day${1===Z.days?'':'s'} with takings${z.missing?`. ${z.missing} cash up${1===z.missing?'':'s'} with no card or cash total left out`:''}${Z.awaiting?`. ${Z.awaiting} shift${1===Z.awaiting?'':'s'} on those days still need${1===Z.awaiting?'s':''} signing off, not counted yet`:''}`:void 0,change:(0,u.changeWords)((0,u.changePct)(Z.pct,ee.pct),D),empty:j||Object.keys(C).length?null==Z.gross?'Not enough data: no cash up in this period has a card or cash total':'Not enough data: no signed-off hours with a pay rate on the days with takings':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(o.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-not-shown",children:(0,f.jsx)(o.Muted,{center:!0,children:u.NOT_SHOWN_YET})})]})};var e,s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=(e=a)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),y=_r(d[10]),v=_r(d[11]),$=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function w({testID:e,label:s,value:t,detail:a,change:r,empty:l}){const c=!!r&&r.startsWith('Up'),h=!!r&&r.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.Muted,{center:!0,children:s}),null==t?(0,f.jsx)(o.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:l}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.T,{testID:`${e}-value`,weight:"semibold",size:y.font.hero,colour:y.colours.gold,center:!0,children:t}),a?(0,f.jsx)(o.Muted,{center:!0,children:a}):null,r?(0,f.jsx)(o.T,{testID:`${e}-change`,center:!0,colour:c?y.colours.goldLight:h?y.colours.muted:y.colours.text,children:r}):null]})]})})}},1509,[1467,17,85,777,858,1008,876,1055,1468,899,804,1242,1243,1057,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]})}},1510,[805,1420,812,822,843,1511,1439,1489,1228,841,1263,899,1512,1514,1440,17,1098,1497,13,385,85,864,1281,777,858,876,851,866,1105,1252,863,804,1184,1057,1139,869,1458,853,1026,1155,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)},1511,[843,17,85,777,845,851,1154,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)}}})]})}},1512,[899,17,264,219,85,1281,777,1260,1263,804,1513,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},1513,[17,219,85,777,1260,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'})})}},1514,[805,1420,17,85,777,851,1260,1261,1262,899,1263,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}),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'}]},1515,[812,891,779,869,1217,17,378,219,385,278,85,831,777,1098,858,876,1516,1520,804,1057,1071,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]}})})},1516,[1517,1519,1518]); +__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)}},1517,[843,1518]); +__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'}},1518,[]); +__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}},1519,[1517,1218]); +__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},1520,[869,824,831,834]); +__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})}},1521,[17,1212,1157,1213,1225,1057,1175,847,856,993,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'},1522,[17,85,777,899,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=v,_e.SmsBubble=C,_e.AlertSettings=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=(0,p.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,p.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,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,k.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,k.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>p.useAlerts.getState().setPrefs({muted:!e})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,y.chime)('bright')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,y.lowChime)(.6)})]}),(0,k.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,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,k.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),p.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindChip,{kind:e,size:30}),(0,k.jsx)(c.default,{style:{flex:1},children:(0,k.jsx)(h.Toggle,{label:p.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>p.useAlerts.getState().setType(e,s)})})]},e))]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,k.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,k.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,k.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${p.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,p.sendTestAlert)(s,e)},e))})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,k.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,k.jsx)(h.Muted,{children:r}),(0,k.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>p.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,k.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,p.requestSystemPermission)()),p.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,p.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,k.jsx)(h.Muted,{children:(0,p.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,k.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,k.jsx)(w.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindIcon,{kind:"email"}),(0,k.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,k.jsx)(h.Badge,{kind:"neutral",label:p.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,k.jsx)(h.Muted,{children:p.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${p.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,k.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,T.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,j.templatesFor)(r),[r]),p=(0,x.useAssistant)(e=>e.enabled)&&b.ASSISTANT_UI,[y,w]=(0,n.useState)('booking'),[A,M]=(0,n.useState)('sms'),B=u[y],I=s=>m.useStore.getState().setTemplate(e,y,s),R=Object.fromEntries(j.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===y?(0,j.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,j.bookingVars)({...S,date:o},s),N=(0,j.toGsm)((0,j.fill)(B.sms,L.sms)),_=(0,j.fill)(B.subject,L.email),D=(0,j.emailHtml)((0,j.fillEmailText)(B.body,L.email),{venue:s.name,preheader:_}),O=!!r?.[y],V=s.settings;return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:j.PREVIEW_BANNER}),(0,k.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,k.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(j.DEFAULT_TEMPLATES).map(e=>(0,k.jsx)(h.Chip,{label:j.TEMPLATE_LABEL[e].title,selected:y===e,onPress:()=>w(e)},e))}),(0,k.jsx)(h.Muted,{children:j.TEMPLATE_LABEL[y].when}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,k.jsxs)(h.Muted,{children:[(0,j.smsParts)(N).chars," characters"]})]}),(0,k.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:B.sms,onChangeText:e=>I({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,j.smsParts)(N).chars>300?(0,k.jsx)(h.T,{size:13,colour:f.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,k.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:B.subject,onChangeText:e=>I({subject:e}),style:h.styles.input}),(0,k.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,k.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:B.body,onChangeText:e=>I({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,k.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[p?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>I(P(B))}):null,O?(0,k.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,y,null)}):null]}),p?(0,k.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,k.jsxs)(h.Muted,{children:["Placeholders: ",j.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:"Text",selected:'sms'===A,onPress:()=>M('sms')}),(0,k.jsx)(h.Chip,{label:"Email",selected:'email'===A,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,k.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,k.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===y?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===A?(0,k.jsx)(C,{text:N,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),_]}),(0,k.jsx)(v,{html:D})]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,k.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,k.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:V.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,k.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!V.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,k.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,T.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),b=t.filter(e=>'all'===l||e.channel===l);return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:f.colours.gold,borderRadius:12,padding:12},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:f.colours.gold,children:(0,j.isLive)()?'Live: messages are sent through your text and email service.':j.PREVIEW_BANNER}),(0,j.isLive)()?null:(0,k.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,k.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,k.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),b.length?null:(0,k.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),b.map(e=>(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,k.jsxs)(h.T,{weight:"semibold",children:[A[e.kind]," \xb7 ",e.ref]})]}),(0,k.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,k.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,k.jsx)(h.T,{size:13,colour:'sent'===e.status?f.colours.ok:'failed'===e.status?f.colours.red:f.colours.amber,children:(0,j.statusLabel)(e)})]}),'sms'===e.channel?(0,k.jsx)(C,{text:e.body}):u===e.id?(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),e.subject]}),(0,k.jsx)(v,{html:e.html??'',height:560})]}):(0,k.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,k.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]),k=_r(d[18]);function v({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 C({text:e,to:t}){const l=(0,j.smsParts)(e);return(0,k.jsxs)(c.default,{style:{gap:4},children:[t?(0,k.jsxs)(h.Muted,{children:["To ",t]}):null,(0,k.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,k.jsx)(h.T,{size:15,children:e})}),(0,k.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const S={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 P(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 A={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1523,[813,812,822,17,219,385,85,777,1230,858,1520,1214,848,1232,1018,804,1027,1057,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:n,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,b=n.settings,x=(0,r.bookingRulesOf)(n),f=(0,o.usePlan)(g),j=(f?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...b.bookingRules??{},...x,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(n),M=(0,d.depositOf)(b),R=b.reservables??(0,i.reservablesOf)(n),O=(0,r.accessGuideOf)(n),[I,A]=(0,t.useState)(null),D=(e,t)=>T({largeGroups:x.largeGroups.map((n,s)=>s===e?{...n,...t}:n)});return(0,y.jsxs)(s.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."}),I?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:I}):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:b.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)(n)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(n)} 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."}),x.largeGroups.map((e,t)=>(0,y.jsxs)(s.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=>D(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>D(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=>D(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:x.largeGroups.filter((e,n)=>n!==t)})}):null]},t)),x.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=x.largeGroups[x.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...x.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:j.map(e=>{const t=x.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(x.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:x.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)(x,n.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(x.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(x.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:x.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!==b.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:x.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),x.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,x.onlineTableMins.map((e,t)=>(0,y.jsxs)(a.Muted,{center:!0,testID:`rules-table-min-${t}`,children:[(0,r.onlineTableMinLine)(e),". Staff can still book them for fewer."]},t)),(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:b.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:M.on&&M.perPersonPence>0?`${w(M.perPersonPence)} per adult for ${M.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),R.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:x.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:x.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:x.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:x.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:x.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:x.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}),A('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:n}=(0,k.useCtx)(6e4),o=T(n),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,b.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,f.isSupabaseConfigured)())return;let e=!0;try{(0,x.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:n})=>{e&&!n&&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)(s.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,f.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,x.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:j.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),n=_r(_d[1]),s=(e=n)&&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]),b=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),j=_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(b.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()},1524,[17,85,777,858,998,1079,1055,841,1105,1252,889,876,920,899,928,971,804,1057,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)})]})]})}},1525,[17,385,85,777,876,1000,851,1001,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]})}},1526,[17,219,385,85,409,777,804,1378,857,1382,863,899,1383,1057,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})},1527,[820,896,1456,17,219,85,777,816,876,895,1000,897,899,1528,804,880,1163,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'}},1528,[]); +__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])},1529,[17,85,777,804,1435,1511,1057,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=w,_e.HelpPage=function({go:e}){const[s,o]=(0,a.useState)(''),[r,h]=(0,a.useState)(null),[p,x]=(0,a.useState)(null),w=(0,a.useMemo)(()=>[...c.HELP,...m],[]),j=(0,a.useMemo)(()=>s.trim()?(0,u.searchHelp)(w,s,10).map(e=>e.a):w.filter(e=>!r||e.topic===r),[s,r,w]);return(0,f.jsxs)(i.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(i.default,{style:[l.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(l.T,{colour:y.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:o,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:y.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(n.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>o('')}):null]}),s?(0,f.jsx)(l.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)(l.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(l.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,n)=>(0,f.jsx)(b,{a:t,go:e,open:p===t.id||!!s&&0===n&&null===p,onToggle:()=>x(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(l.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",colour:y.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(l.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(l.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=function({go:e}){const{rid:t,today:s}=(0,x.useCtx)(6e4),n={rid:t,today:s,go:(t,s)=>e(t,s??null)},[o,r]=(0,a.useState)(''),[h,u]=(0,a.useState)(null),[m,b]=(0,a.useState)(null),C=async()=>{const e=o.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,n);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...j(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(i.default,{testID:"ask-assistant",children:(0,f.jsxs)(l.Card,{highlight:y.colours.gold,children:[(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(i.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(l.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:o,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:C,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(l.Button,{label:"Ask",testID:"assistant-ask",disabled:!o.trim(),onPress:C,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(l.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)(l.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(k,{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,n,!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,m?(0,f.jsxs)(i.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(l.Banner,{kind:'done'===m.kind?'success':'error'===m.kind?'warn':'demo'===m.kind?'demo':'info',title:m.text}),m.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>w(s,e)}):null]},t)})]}):null,(0,f.jsx)(l.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),o=e(_r(d[4])),i=e(_r(d[5])),l=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),y=_r(d[12]),x=_r(d[13]),f=_r(d[14]);const m=[{id:'ai-assistant-pairing',kind:'faq',topic:'Accounts',title:'Can I connect my own AI assistant?',keywords:['assistant','ai','pair','pairing','grok','bot','unpair','approve','draft','log'],body:'AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. In the connected assistant, it can answer questions about your venue and give advice from the venue data it is allowed to look up. It can draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged, including look-ups. Open More \u203a Account \u203a Assistants, as an owner, on Full Restaurant Pro, SuperPro or the early adopter offer. It is not included with Customer & Takeaway App, and there is no AI assistant on the Display app.',showMe:{tab:'more',page:'assistants',target:{testID:'assistants-page'},hint:'Pair, switch off or unpair an assistant here. Owners only.'}},{id:'customer-support',kind:'faq',topic:'Accounts',title:'How do I contact CoverCharge support?',keywords:['support','customer support','help','email','picture','photo','screenshot','contact','covercharge'],body:'Customer support is at the very bottom of Home, and at the bottom of More, as an owner. Write a message, attach one picture if you like (a photo or a screenshot), and tap Send to CoverCharge. It is sent with your venue name, your name and email, and the app version. You will see \u201cSent. We\u2019ll reply by email.\u201d if it went through, or an error with a way to try again. There is no Customer support on the Display, Staff, Front of House or Head Chef apps.',showMe:{tab:'more',page:'support',target:{testID:'customer-support'},hint:'Write a message, attach a picture if you like, and send it to CoverCharge. Owners only.'}},{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:'In the Managers app go to More \u203a Run the day \u203a Display settings 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. There is no wipe or unpair button on the Display itself. To switch a Display off, go to Settings \u203a Displays and choose Switch off.',showMe:{tab:'more',page:'displaysettings',target:{testID:'wipe-setting'},hint:'Sign out and wipe is in Display settings, in the Managers app only.'}}];function w(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 b({a:e,go:t,open:s,onToggle:n}){return(0,f.jsx)(i.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(o.default,{accessibilityRole:"button",onPress:n,children:(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(i.default,{style:{flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(l.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(l.T,{colour:y.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(i.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(l.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>w(e,t)})}):null]})})}function j(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function k({p:e,today:t,onChange:n,onConfirm:a,onCancel:o}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>n({...e.params,[t]:s}),x=e.action,m=e.params,w=x.params.every(e=>!e.required||void 0!==m[e.name]&&''!==m[e.name]);return(0,f.jsxs)(i.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?y.colours.red:y.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':y.colours.okBg},children:[(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[x.risk]}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:x.title})]}),x.form&&'add_walkin'===x.id?(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Covers",value:void 0===m.covers?'':String(m.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Table (optional)",value:void 0===m.table?'':String(m.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,x.form&&'add_rota_shift'===x.id?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{size:12,children:"Who"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(l.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:m.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1.3},children:(0,f.jsx)(l.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(m.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Start (24h)",value:String(m.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"End (24h)",value:String(m.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(l.T,{children:w?x.preview(m,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(l.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(l.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(l.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!w,onPress:a,style:{flex:1}}),(0,f.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:o,style:{flex:1}})]})]})}},1530,[812,1033,779,17,385,85,777,876,1481,1531,1532,1533,804,1057,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.','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:'guest-change-link',kind:'faq',topic:'Bookings',title:'Can guests change or cancel their own booking?',keywords:['change','cancel','link','email','guest','move','booking'],body:'Yes. The confirmation email has a "Change or cancel your booking" link for that one booking, with "Or call us on (your number) and quote your booking details." underneath. Guests can change the date, time or party size within your online booking rules, or cancel after confirming. Bookings with a deposit say "please call us" instead. Takeaway orders can\u2019t be changed or cancelled by the guest, and their email has no link. You see every change on the Display and in Managers, marked as changed by the guest. The link stops working at the booking time.'},{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:'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 takings \xf7 Covers, by day and by week. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). 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.'},{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.'}],o=t=>a.find(a=>a.id===t)},1531,[]); +__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}},1532,[]); +__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}},1533,[1534,1100,843,1535,1536,876,858,998,1481,1531,1532,1538,1537,1540,1541,996,997]); +__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))}}]},1534,[1064,1063,1023]); +__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.`)}}]},1535,[896,1100,820,843,1121,1098,1115,922,858,816,998,895,897,1010,876,1067,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]),n=_r(_d[3]),r=_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)=>r.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(),n=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(n){const e=Number(/\d/.test(n[1])?n[1]:n[2]),a=L.indexOf(/\d/.test(n[1])?n[2]:n[1]);let r=Number(t.slice(0,4));return`${r}-${A(a+1)}-${A(e)}`e.active)){const n=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),r=Math.min(...n.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));r<1/0&&a.push({s:e,at:r})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>r.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(),n=U(e);if(!n.length)return;const r=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(r)return n.find(e=>e.number===Number(r[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=n.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===n.length?n[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const r=a.useStore.getState(),i=r.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=n.useFloor.getState(),c=d.plans[e]??(0,n.seedPlan)(e),h=r.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,r.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 n=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return n?`Seat ${Y(a)}, at table ${n}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const r=z(a.rid,e.who);if(!r)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,r.partySize);return i?(await t.repo.waitlist.setStatus(r.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,r.partySize,i,`From waitlist #${r.number}`),(0,n.tablesOf)(i).forEach(e=>n.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${r.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=r.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),n=j(String(t??''),e.today);return n?a.find(e=>e.date===n):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(),n=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(n){const e=j(n[1],t),a=j(n[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!n||e.kind===n)),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 ne(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),n=new Date(a+'T00:00:00').getTime(),r=n+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=n&&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>=n&&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)()),n=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),r=(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=>r.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),n):[];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 n;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(n?.s??0)&&(n={m:t,s:e})}return n?.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 n=z(a.rid,e.who);return n?(await t.repo.waitlist.setStatus(n.id,'removed'),`Done: number ${n.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,r)=>{const i=z(r.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===r.rid);return n.useFloor.getState().logSms(r.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?r.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(r.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),n=E(e.with);return n&&n.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(n.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),n=E(e.with);return a&&t.whoId?n&&n.id!==t.whoId?(r.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:n.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(n.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)())),n=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:n&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(n[1])?n[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=r.useOwner.getState().shifts.find(e=>e.id===t.shiftId),n=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${n}\u2019s swap with ${i}`:t.toId?`${i} covering ${n}`:`${n}\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 ${n}\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=r.useOwner.getState(),n=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)}${n?` (${M[n.day]} ${R(n.start)}\u2013${R(n.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 n=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: ${n.n} checks, ${n.bad} out of range${n.bad?`, ${n.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:n}=ne(t.today,t),r=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(r)return`This week is already signed off by ${r.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${n.entries} checks, ${n.outOfRange} out of range, ${n.actions} with an action, diary signed ${n.daysSigned} of 7 days.`;return n.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:n}=ne(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':n.actions!0),note:'Signed by voice: yes to all.',summary:n}),'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),n=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${n}; 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)),n='Near miss'===a.category,r=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(r)}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??'')||(n?'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:n,rem:r}=se(t,e.task);return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?`${_(n.text)} is already ticked today.`:`Tick off today\u2019s task ${_(n.text)}?`:r?`Mark the reminder ${_(r.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:n,rem:r}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,n.id,a,i),`Done: ${_(n.text)} ticked.`):r?(c.useReminders.getState().markDone({rid:t.rid,reminderId:r.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),r=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=n?.sections.find(e=>r.includes(e.toLowerCase())||r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=String(e.section??n?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${r} 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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(r)||r<=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??n?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:r,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 n=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 n?{dish:n[1],field:'description',value:n[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 n=de(t.rid,e.dish),r=String(e.value??'').trim();return n?r.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(n.id,'name'===e.field?{name:r}:{description:r}),'name'===e.field?`Done: renamed to ${r}.`:`Done: description of ${n.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 n=(0,$.findCard)(t.rid,a.dish);return n?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${n.dish}\u2019s recipe card?${n.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)),n=a&&(0,$.findCard)(t.rid,a.dish);return a&&n?(await(0,y.recipeCards)().update(n.id,{ingredients:[...n.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 ${n.dish}.${n.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,n=String(e.step??'').trim();return!a||n.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,n]},{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],n=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),r=/\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:r,reason:n?.[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 n=e.action??'in',r=(0,g.managerClockAction)(n,{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 r.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[n]} at ${D()}.${r.warn?' '+r.warn:''}`:'Nothing changed: '+r.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 n=h.useCashUp.getState(),r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,r?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(n.tips.filter(e=>e.rid===t.rid),n.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: 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 n='yesterday'===e.day?(0,l.ymdOf)(a):e.day,r=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!n||e.date===n)).sort((e,t)=>t.date.localeCompare(e.date)),i=r[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: takings ${fe((0,p.tillTakingsOf)(i.vals))} (card + cash \u2212 card tips), tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:n?`There\u2019s no cash-up for ${(0,$.niceDay)(n)}.`:'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 r='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,n.tablesOf)(a).forEach(e=>n.useFloor.getState().setLive(t.rid,e,{note:r||void 0})),r?`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 n=(0,$.appNow)();return r.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(n)} ${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',n=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),r=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:n?.[1]?.trim(),time:r?(0,$.hm)(r[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??''),n=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(n)}, ${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(),n=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(n))return'Nothing changed: I need the wording and a time like 21:00.';const r=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:r,time:n,audience:e.audience??'all'}),'Done: reminder added.'}}]},1536,[820,858,816,998,876,1003,1014,1015,927,926,1008,839,1034,1035,1036,1004,1067,867,1076,995,854,1537,1535]); +__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.'}}]},1537,[820,891,1100,843,1140,1263,858,816,998,1003,910,846,845,1076,1077,995,1004,851,1538,1539]); +__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)}))},1538,[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)}))},1539,[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)])},1540,[816,876,910,851,1537,1017,1071]); +__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))'},1541,[]); +__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,u.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:u.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:u.VOICE_ROLE_LABEL[s],value:(0,u.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,h.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:p}=(0,f.useCtx)(6e4),u=(0,r.useDrafts)(e=>e.drafts),h=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=u.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),D='owner'===p||'manager'===p,C=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:r.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&&D?(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'})}),C(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${C(e).name} ordering`,onPress:()=>{t.default.openURL(C(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:"Drafts saved earlier (bookings, supplier shopping lists, offers, events, specials, messages and payments) wait 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."}),D?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:()=>{h(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,p.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,p.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. 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]),r=_r(_d[6]),l=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),h=_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'}}},1542,[17,362,85,777,804,1477,1538,1489,1539,1543,1217,1544,1057,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return s}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(f(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(f(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),s=(e,n,t)=>!1!==e[n]?.[t],f=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1543,[824,831,834]); +__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])},1544,[17,85,777,804,1545,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.'},1545,[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}},1546,[17,779,85,777,845,1260,1547,1548,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'},1547,[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()})},1548,[899,1547,1263]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:l,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,o.useCashUp)(e=>e.cashUps),k=(0,o.useCashSettings)(e),w=(0,d.useNightlyPrefs)(s=>s.email[e]??!1),T=(0,d.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(s=>s.rid===e&&s.on).map(e=>e.name),[N,U]=(0,s.useState)((0,u.addDaysYmd)(v,-1)),P=(0,u.cashFieldsForRecord)(k.cashFields,(0,u.cashUpRecordFor)(e,l.settings.cashUpRecord)),R=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:P,soldOut:C}),_='anchorage'!==e&&w,D=[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:D.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:()=>U(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:R.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(R.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(R.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(R.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:R.takings}),(0,j.jsx)(x,{label:"Tips",value:R.tips}),(0,j.jsx)(x,{label:"Takings last week",value:R.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:R.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:R.soldOut.length?R.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),R.cashUp.length?R.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:_,onChange:s=>T(e,s)}):null]})};var e,s=_r(_d[0]),l=_r(_d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),d=_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:s})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${s}`,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:s})]})},1549,[17,85,777,858,1008,1550,891,839,1551,1020,804,1057,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}))},1550,[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.tillTakingsOf)(k.vals):null,N=(0,l.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:s(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(y),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(O?(0,t.tillTakingsOf)(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]),l=r(d[2]);const s=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?s(t):String(t);function u(t,l,u){const c=[];for(const f of l){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const l=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==l?'Not entered':s(l)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!l.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const l=(0,n.expectedCashInDrawer)(t);null!=l&&c.push({label:'Expected cash in the drawer',value:s(l)})}return c}},1551,[839,1009,1469]); +__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.SupportChatPage=function(){const{r:e,me:f,meId:x}=(0,h.useCtx)(6e4),[j,v]=(0,s.useState)(''),[C,I]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[R,D]=(0,s.useState)('idle'),[L,P]=(0,s.useState)(''),[k,B]=(0,s.useState)(''),[_,T]=(0,s.useState)('');(0,s.useEffect)(()=>{(0,p.signedInEmail)().then(B)},[]);const E=async e=>{T('');try{const t=await(0,c.capturePlatingPhoto)(e);t&&(I(t),D(e=>'sent'===e?'idle':e))}catch(e){T(e instanceof Error?e.message:'Could not add that picture.')}},H=async()=>{const t=j.trim();if(!t||w)return;S(!0),P(''),D('idle');const s=await(0,p.writeSupportRequest)({venueName:e.name,body:t,fromName:f.replace(' (example)',''),fromEmail:k,staffRef:x||'',appVersion:u.APP_VERSION,photoDataUrl:C?.dataUrl??null});if(S(!1),s.ok)return v(''),I(null),D('sent'),void P(b);D('error'),P(s.message)};return(0,y.jsxs)(l.default,{testID:"customer-support",style:{gap:12,alignItems:'center',width:'100%',paddingBottom:8},children:[(0,y.jsx)(o.T,{center:!0,weight:"bold",colour:n.colours.gold,accessibilityRole:"header",children:"Customer support"}),(0,y.jsx)(o.Muted,{center:!0,children:"Send a message to CoverCharge. You can attach one picture, such as a photo or a screenshot. We'll reply by email."}),'sent'===R?(0,y.jsx)(l.default,{testID:"support-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:b,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"success",title:b})}):null,'error'===R?(0,y.jsx)(l.default,{testID:"support-error",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:L,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"danger",title:L})}):null,(0,y.jsx)(t.TextInput,{testID:"support-message",accessibilityLabel:"Your message to CoverCharge",value:j,onChangeText:e=>{v(e),'sent'===R&&D('idle')},placeholder:"Write your message",placeholderTextColor:n.colours.muted,multiline:!0,style:{width:'100%',minHeight:120,borderWidth:1,borderColor:n.colours.border,borderRadius:12,padding:12,color:n.colours.text,textAlign:'center'}}),C?(0,y.jsxs)(l.default,{testID:"support-photo-preview",style:{alignItems:'center',width:'100%',gap:8},children:[(0,y.jsx)(r.default,{source:{uri:C.dataUrl},style:{width:240,height:180,borderRadius:12,backgroundColor:n.colours.surface2},accessibilityLabel:"Attached picture preview"}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Remove picture",accessibilityLabel:"Remove the attached picture",testID:"support-photo-remove",onPress:()=>I(null),style:{minHeight:48}})]}):(0,y.jsxs)(l.default,{style:{width:'100%',gap:8,alignItems:'center'},children:[(0,y.jsx)(o.Button,{kind:"secondary",label:"Take a photo",accessibilityLabel:"Take a photo to attach",testID:"support-photo-camera",onPress:()=>{E('camera')},style:{minHeight:48,width:'100%'}}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a picture or screenshot from your gallery",testID:"support-photo-gallery",onPress:()=>{E('library')},style:{minHeight:48,width:'100%'}})]}),_?(0,y.jsx)(o.Muted,{center:!0,testID:"support-photo-error",children:_}):null,(0,y.jsx)(o.Button,{testID:"support-send",label:"Send to CoverCharge",accessibilityLabel:"Send to CoverCharge",disabled:!j.trim()||w,onPress:()=>{H()},style:{minHeight:56,width:'100%'}}),w?(0,y.jsx)(l.default,{accessibilityLiveRegion:"polite",style:{width:'100%'},children:(0,y.jsx)(o.Muted,{center:!0,testID:"support-sending",children:"Sending\u2026"})}):null]})};var t=_r(d[0]),s=_r(d[1]),r=e(_r(d[2])),l=e(_r(d[3])),o=_r(d[4]),n=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),y=_r(d[10]);const b="Sent. We'll reply by email."},1552,[812,17,319,85,777,804,1082,978,1553,1057,8]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPPORT_BUCKET",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SUPPORT_SEND_FAILED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SUPPORT_SIGN_IN",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SUPPORT_NO_EMAIL",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SUPPORT_PHOTO_FAILED",{enumerable:!0,get:function(){return l}}),e.writeSupportMessage=async function(o){if(!t.RELEASE.supportSync)return{ok:!1,message:n.SUPPORT_NOT_SENT};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:n.SUPPORT_NOT_SENT};const c=u.useSync.getState().venueId;if(!c)return{ok:!1,message:`${n.SUPPORT_NOT_SENT} Sign in and try again.`};try{const t=(0,i.getSupabase)(),{error:s}=await t.from('support_messages').insert({venue_id:c,body:o.text,from_name:o.from,staff_ref:o.staffRef||null});return s?{ok:!1,message:n.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:n.SUPPORT_NOT_SENT}}},e.writeSupportRequest=async function(t){if('undefined'!=typeof globalThis&&globalThis.__CC_SUPPORT_FAKE_SEND)return{ok:!0,id:'preview-test',emailed:!0};const n=t.body.trim().slice(0,4e3),S=t.fromName.trim().slice(0,80),y=t.fromEmail.trim().slice(0,254),P=t.venueName.trim().slice(0,120);if(!n||!S||!P)return{ok:!1,message:f};if(!y||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y))return{ok:!1,message:m};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:p};const b=u.useSync.getState().venueId;if(!b)return{ok:!1,message:p};const T=globalThis.crypto?.randomUUID?.()??`00000000-0000-4000-8000-${Date.now().toString(16).padStart(12,'0')}`,O=(0,i.getSupabase)();let h=null;if(t.photoDataUrl)try{const n=_(t.photoDataUrl);h=`${b}/${T}.jpg`;const{error:o}=await O.storage.from(c).upload(h,n,{contentType:'image/jpeg',upsert:!1});if(o)return{ok:!1,message:l}}catch{return{ok:!1,message:l}}const E={id:T,venue_id:b,venue_name:P,body:n,from_name:S,from_email:y,staff_ref:t.staffRef||null,app_version:(t.appVersion||o.APP_VERSION).slice(0,40),photo_path:h},{error:N}=await O.from('support_requests').insert(E);if(N)return{ok:!1,message:f};let U=!1;try{const t=await O.functions.invoke('send-support-email',{body:{request_id:T}}),n=t.data;U=!t.error&&!!n?.sent}catch{U=!1}return{ok:!0,id:T,emailed:U}},e.signedInEmail=async function(){if(!(0,s.isSupabaseConfigured)())return'';try{const{data:t}=await(0,i.getSupabase)().auth.getUser();return(t.user?.email??'').trim()}catch{return''}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),i=r(d[4]),u=r(d[5]);const c='support-photos',f='Could not send. Check your connection and try again.',p='Could not send. Sign in and try again.',m='Your sign-in has no email. Sign in again and try again.',l='Could not attach the picture. Try a smaller photo, or send without a picture.';function _(t){const n=/^data:([^;]+);base64,(.+)$/.exec(t);if(!n)throw new Error('bad picture');const o=atob(n[2]),s=new Uint8Array(o.length);for(let t=0;t{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{}}},1554,[17,264,219,85,777,812,804,899,1430,1188,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+'},1555,[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 ']]},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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:te,height:se}=(0,a.default)(),[oe,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(!1),[le,ae]=(0,t.useState)(!1),[de,ce]=(0,t.useState)(''),[ue,ge]=(0,t.useState)(!1),[he,pe]=(0,t.useState)(!1),[be,fe]=(0,t.useState)(!1),[me,xe]=(0,t.useState)(!1),ke=(0,t.useRef)(null),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(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,M.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const Ce=(0,K.useTakingsAllowed)(s),ve=(0,t.useCallback)(e=>{const t=(0,A.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),De=(0,t.useMemo)(()=>(0,V.buttonsFor)({takings:Ce,pageOk:ve}),[Ce,ve]),Ie=oe?(0,V.tabsFor)(oe.btn,{takings:Ce,pageOk:ve}):[],Se=(0,t.useCallback)((e,t)=>{const s=(0,V.tabsFor)(e,{takings:Ce,pageOk:ve});s.length&&(ie(!1),ae(!1),ce(''),ne({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[Ce,ve]),Te=De.find(e=>'settings'===e.id),Re=(0,t.useCallback)(e=>{const t=De.find(t=>t.pages.some(t=>t.id===e));t?Se(t,e):Te&&ve(e)&&(ie(!1),ae(!1),ce(''),ne({btn:Te,tab:'@desk-settings',page:e}))},[De,Se,Te,ve]),Oe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Re(t);else{if('bookings'===e){const e=De.find(e=>'bookings'===e.id);return void(e&&Se(e,'@bookings'))}if('chat'===e){const e=De.find(e=>'chat'===e.id);return void(e&&Se(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Te&&Se(Te):ne(t=>({btn:t?.btn??De[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else ne(null)},[De,Se,Re,Te]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Oe}),()=>T.useVoiceNav.setState({go:null})),[Oe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Oe('bookings'):'chat'===e?Oe('chat'):Oe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Pe=!oe||De.some(e=>e.id===oe.btn.id)&&Ie.some(e=>e.id===oe.tab)&&(!oe.page||ve(oe.page));(0,t.useEffect)(()=>{if(!Pe){const e=setTimeout(()=>ne(null),0);return()=>clearTimeout(e)}},[Pe]);const Le=oe?.page?(0,A.pageFor)(oe.page):void 0,We=oe?(0,_.deskCopy)(Le?.title??oe.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${We} \xb7 The Anchorage \xb7 CoverCharge for desktop`),we.current?.scrollTo?.({y:0,animated:!1}),oe){const e=setTimeout(()=>Y(je.current),80);return()=>clearTimeout(e)}},[We,oe?.tab,oe?.page]),(0,t.useEffect)(()=>{if(le){const e=setTimeout(()=>ke.current?.focus?.(),100);return()=>clearTimeout(e)}},[le]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=q(e.target),s=(0,_.commandKey)(e,t);if('escape'===s){if(le||ue||he||be)return e.preventDefault(),ae(!1),ge(!1),pe(!1),void fe(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return re?(e.preventDefault(),void ie(!1)):void(oe&&(e.preventDefault(),ne(null)))}if(le||ue||he||be||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),ie(!1),void ae(!0);if('help'===s)return e.preventDefault(),void ge(!0);if('filter'===s&&ye.current&&oe)return e.preventDefault(),void ye.current?.focus?.();const o=t?null:(0,_.shortcutIndex)(e);null!=o&&De[o]&&(e.preventDefault(),Se(De[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[le,ue,he,be,re,oe,De,Se]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Oe,globalThis.__deskOpen=(e,t)=>{const s=De.find(t=>t.id===e);s&&Se(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Oe,De,Se]);const Be=(0,t.useMemo)(()=>{const e=de.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De.flatMap(e=>(0,V.tabsFor)(e,{takings:Ce,pageOk:ve}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Se(e,t.id)}))),o=new Set(De.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...A.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,_.deskCopy)(e.title),sub:(0,_.deskCopy)(e.sub??''),run:()=>Re(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[de,De,s,Ce,ve,Se,Re]),He=(0,N.ddmmyyyy)(o),Me=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),Ee=b?(0,B.authorityRole)(b):s,$e=(b?.name??h).replace(' (example)',''),ze='owner'===Ee?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Ae=e=>(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Fe=e=>{const t=(0,A.pageFor)(e);return!t||t.can&&!t.can(s)?(0,X.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,X.jsx)(t.C,{go:Oe})})};return(0,X.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,X.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>oe?Y(je.current):ie(!0),children:(0,X.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:oe?'Skip to main content':'Open the owner tools menu'})}),(0,X.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,X.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:te,headerExtra:(0,X.jsx)(J,{open:re,onPress:()=>ie(!0)}),subHeader:(0,X.jsx)(Q,{name:$e,access:ze,day:He,at:Me})}),oe&&Pe?(0,X.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,X.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,X.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,X.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:oe.page?'Back to all settings':`Close ${oe.btn.label}, back to the floor plan`,onPress:()=>oe.page?ne({...oe,page:null}):ne(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,X.jsx)(f.T,{weight:"semibold",center:!0,children:oe.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,X.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,X.jsx)(l.default,{ref:je,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,X.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:We})}),(0,X.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,_.deskCopy)(Le?.sub??oe.btn.hint)})]}),(0,X.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,X.jsx)(J,{testID:"desk-menu-button-page",open:re,onPress:()=>ie(!0)})})]}),Ie.length>1&&!oe.page?(0,X.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Ie.map(e=>{const t=e.id===oe.tab;return(0,X.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>ne({btn:oe.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?Z:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,X.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,X.jsx)(i.default,{ref:we,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(!oe||!Pe)return null;if(oe.page)return Fe(oe.page);switch(oe.tab){case'@desk-bookings':return(0,X.jsx)(K.DesktopBookings,{filterRef:ye});case'@desk-hours':return(0,X.jsx)(K.DesktopHours,{go:Oe,filterRef:ye});case'@desk-takings':return Ce?(0,X.jsx)(K.DesktopTakings,{go:Oe}):(0,X.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,X.jsx)(K.DesktopSettings,{open:e=>ne(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,X.jsx)(G.DeskPermissions,{});case'@desk-leavers':return(0,X.jsx)(G.DeskLeavers,{});case'@desk-temps':return Ae((0,X.jsx)(G.DeskTemps,{}));case'@desk-bookinghistory':return Ae((0,X.jsx)(G.DeskCoversHistory,{}));case'@bookings':return(0,X.jsx)(H.Bookings,{go:Oe});case'@chat':return(0,X.jsx)(M.Chat,{go:Oe});case'@noshows':return Ae((0,X.jsx)(W.NoShows,{go:Oe}));case'@orders':return(0,X.jsx)($.Orders,{});case'@forecast':return(0,X.jsx)(E.Forecasts,{go:Oe});default:return Fe(oe.tab)}})()})]}):null]}),(0,X.jsx)(ee,{visible:re,buttons:De,current:oe?.btn.id,W:te,H:se,onClose:()=>ie(!1),onPick:e=>Se(e),onFind:()=>{ie(!1),ae(!0)},onKeys:()=>{ie(!1),ge(!0)},onInstall:()=>{ie(!1),pe(!0)},onSignOut:()=>{ie(!1),fe(!0)}}),le?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ae(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,X.jsx)(p.TextInput,{ref:ke,value:de,onChangeText:ce,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,X.jsx)(l.default,{'aria-live':'polite',children:(0,X.jsxs)(f.Muted,{center:!0,children:[Be.length," pages"]})}),Be.slice(0,60).map(e=>(0,X.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,X.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,X.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ue?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ge(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,_.SHORTCUTS)((0,F.isMac)()).map(([e,t])=>(0,X.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,X.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,X.jsx)(f.T,{center:!0,children:t})]},e)),(0,X.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,be?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>fe(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,X.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,X.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,X.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>fe(!1),testID:"desk-signout-cancel"}),(0,X.jsx)(f.Button,{label:me?'Signing out\u2026':'Sign out',disabled:me,onPress:async()=>{xe(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,he?(0,X.jsx)(f.Sheet,{visible:!0,onClose:()=>pe(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,X.jsx)(U.DesktopInstallPage,{})}):null,(0,X.jsx)(k.SeatAllergenReminder,{rid:e}),(0,X.jsx)(x.PrintHost,{rid:e}),(0,X.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Oe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,X.jsx)(z.OnboardingHost,{go:Oe}),(0,X.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]);r(d[37]);var F=r(d[38]),_=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]);const q=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Y=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},Z='rgba(201,162,74,0.14)';function J({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,X.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,X.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,X.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,X.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function Q({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,X.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,X.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,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function ee({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,V.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(()=>Y(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,F.isMac)();return(0,X.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,X.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,X.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,X.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,X.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,X.jsx)(l.default,{style:{width:56}}),(0,X.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,X.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,X.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,X.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,V.deskShortcut)(t,B);return(0,X.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,X.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:Z,alignItems:'center',justifyContent:'center'},children:(0,X.jsx)(G.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,X.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,X.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,X.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1558,[17,266,347,219,385,278,85,409,19,780,812,779,777,1230,1394,1087,1481,1086,1084,1232,1245,891,876,1032,1489,880,899,804,1340,1559,1057,1419,1161,1483,1485,1474,1458,1487,1555,1557,1565,1566,1567,1570,1573,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))}},1559,[17,266,347,219,385,278,85,409,780,779,1340,1458,1487,1419,1161,1485,1483,1057,1026,777,858,876,863,899,880,804,1560,1561,1562,1563,1564,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1560,[]); +__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])},1561,[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])},1562,[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])},1563,[17,385,1163,1164,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},1564,[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,b=Math.round(1.4*h),k=Math.max(48,Math.min(72,c-2*b-14,l-34));return{panelW:n,colW:l,per:c,circle:k,label:h,lineH:b,icon:Math.round(.44*k),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}],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'},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','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}`},1565,[1560]); +__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)},1566,[]); +__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,f.useOwner)(e=>e.staff),x=(0,f.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)),T=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=T.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,f.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,D.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,m.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,D.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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,D.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,D.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,f]=(0,t.useState)('next7'),[m,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[T,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,D.bookingColumns)(T),[T]),E=(0,t.useMemo)(()=>(0,D.sortRows)((0,D.filterRows)((0,D.bookingsBetween)(r,W,L,m),z,x),z.find(e=>e.key===$),M),[r,W,L,m,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:()=>f(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:m===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:T?'Hide phone numbers':'Show phone numbers',selected:T,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,D.csvName)('bookings',W,L),(0,D.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,D.ddmmyyyy)(W)}${L!==W?` to ${(0,D.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,D.ddmmyyyy)(W)} to ${(0,D.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,D.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${D.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,D.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",D.STATUS_WORD[G.status]??G.status]}),G.phone&&T?(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,f.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,m]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,T]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,f.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,D.ukTime)(e.in),outT:(0,D.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,D.sortRows)((0,D.filterRows)(O.filter(e=>'all'===p||e.status===p),D.HOURS_COLUMNS,y),D.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:m,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,D.csvName)('hours',R,M),(0,D.toCsv)(N,D.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,D.hm)((0,D.totalPaid)(N))} paid \xb7 ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`,cols:D.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(T(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,D.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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:T.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...T.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!T.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,T.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,T.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,T.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]),f=_r(_d[13]),m=_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]),T=_r(_d[23]),D=_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 f.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]}},1567,[17,385,85,409,812,777,1072,1032,1180,1122,1091,858,1008,876,1055,839,889,899,804,1419,1057,1458,1568,1557,1566,1569,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},1568,[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)}.`}},1569,[17,85,780,777,804,1568,1566,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}]},1570,[17,264,385,85,780,777,858,876,1571,915,1215,1465,804,1561,1057,1568,1572,1566,1569,1567,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)}))},1571,[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)},1572,[915]); +__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))})]})}},1573,[17,85,777,804,1574,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)},1574,[]); +__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:h,today:O,now:I,meId:N,me:X}=(0,A.useCtx)(3e4);(0,x.useTipsPosted)(e,O);const Z=(0,A.useSignedIn)();(0,m.useSoldOutLink)(!0,(Z?.name??X).replace(' (example)',''));const[q,J]=(0,s.useState)({kind:'tab',tab:'home'}),[Q,Y]=(0,s.useState)(''),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,A.ensureAttendance)(O,I),(0,D.ensureChat)(I)},[O]),globalThis.__ccNow=I.getTime();const te=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=V[t];return void J(e?{kind:'edit',id:e}:{kind:'page',id:t})}J('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:te}),()=>C.useVoiceNav.setState({go:null})),[te]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=te,globalThis.__deskGo=e=>J(e))},[te]),(0,v.useAlertWatcher)(e,{nag:'staff'!==h}),(0,w.useScheduledNotices)({rid:e,staffId:Z?.id??'',name:X,onOpen:e=>'bookings'===e?te('bookings'):'chat'===e?te('chat'):te('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==h&&!!Z});const ae=(0,s.useMemo)(()=>[...$,...F].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 ee.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=ae[Number(e.key)-1];return void(t&&(e.preventDefault(),J(t)))}if('z'===t&&!U(e.target)){const t=(0,z.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!U(e.target)){const t=(0,z.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae]);const se=B.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(h))&&!V[e.id]),ne=(0,s.useMemo)(()=>{const e=Q.trim().toLowerCase(),t={};return se.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[se,Q]),oe=$.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(h)),re=p.CAN.forecasts(h)?F:F.filter(e=>'rota'===e.s.id),ie='page'===q.kind?(0,B.pageFor)(q.id):void 0,le='tab'===q.kind?$.find(e=>K(e.s,q))?.label:'edit'===q.kind?F.find(e=>K(e.s,q))?.label:ie?.title,de='tab'===q.kind?$.find(e=>K(e.s,q))?.tip:'page'===q.kind?`${ie?.sub??''}. Press ${(0,_.CMD)()}K to jump to any page.`:'',ue=({label:e,s:t,n:a})=>{const s=K(t,q);return(0,W.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>J(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,W.jsx)(f.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,W.jsxs)(f.T,{size:11,colour:S.colours.muted,children:[(0,_.CMD)(),a]}):null]})},ce=({t:e})=>(0,W.jsx)(f.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),be='owner'===h?'OWNER':'manager'===h?'MANAGER':'STAFF';return(0,W.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,W.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,W.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(f.Row,{gap:10,children:[(0,W.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(u.VenueName,{name:c.name}),(0,W.jsx)(f.Row,{gap:6,children:(0,W.jsx)(l.AppBadge,{label:be})})]})]}),(0,W.jsx)(u.PoweredBy,{}),(0,W.jsx)(a.TextInput,{ref:ee,testID:"side-filter",value:Q,onChangeText:Y,placeholder:`Find a page (${(0,_.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[f.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,W.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Q?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{t:"Run the day"}),oe.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:t+1},e.label)),(0,W.jsx)(ce,{t:"Drag-and-drop editors"}),re.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:oe.length+t+1},e.label))]}),Object.entries(ne).map(([e,t])=>(0,W.jsxs)(r.default,{children:[(0,W.jsx)(ce,{t:e}),t.map(e=>(0,W.jsx)(ue,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,W.jsxs)(r.default,{style:{flex:1},children:[(0,W.jsx)(r.default,{testID:"desk-title",children:(0,W.jsx)(f.T,{size:24,weight:"bold",children:le??''})}),(0,W.jsxs)(f.Muted,{size:12,children:[Z?`Signed in as ${Z.name} \xb7 ${p.ROLE_LABEL[h]}`:`Preview \xb7 ${p.ROLE_LABEL[h]}`," \xb7 ",c.name]})]})}),(0,W.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[de?(0,W.jsx)(H.Tip,{children:de}):null,'edit'===q.kind?(0,W.jsx)(G,{id:q.id,rid:e,me:X,role:'owner'===h?'owner':'manager',today:O,venue:c.name}):(0,W.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===q.kind&&'home'===q.tab?(0,W.jsx)(L.Dashboard,{go:te}):null,'tab'===q.kind&&'orders'===q.tab?(0,W.jsx)(P.Orders,{}):null,'tab'===q.kind&&'bookings'===q.tab?(0,W.jsx)(E.Bookings,{}):null,'tab'===q.kind&&'forecast'===q.tab?(0,W.jsx)(R.Forecasts,{go:te}):null,'tab'===q.kind&&'chat'===q.tab?(0,W.jsx)(D.Chat,{go:te}):null,ie?(0,W.jsx)(ie.C,{go:te}):'page'===q.kind?(0,W.jsx)(f.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,W.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==h?(0,W.jsx)(g.PrintHost,{rid:e}):null,'staff'!==h?(0,W.jsx)(b.AlertHost,{variant:"managers",rid:e,me:X,onOpen:e=>te('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,W.jsx)(M.OnboardingHost,{go:te}),(0,W.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]),f=_r(d[12]),h=_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]);_r(d[33]);var O=_r(d[34]),_=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]);const $=[{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.'}],F=[{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:''}],V={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},K=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),U=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function G({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,h.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,W.jsx)(I.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,W.jsx)(N.RotaEditor,{today:o}):'brand'===e?(0,W.jsx)(O.BrandEditor,{rid:t}):(0,W.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,W.jsxs)(H.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,_.CMD)(),"Z undoes, then Save."]}),g?(0,W.jsx)(f.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,W.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,W.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{h.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)})]})}},1575,[813,812,17,385,278,85,19,1363,857,1366,1230,1394,777,998,876,891,1032,1481,1087,1086,1084,1489,1232,880,804,1419,1161,1057,1432,1483,1474,1485,1458,1487,1576,1555,1578,1580,1582,1579,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])},1576,[17,278,85,1502,857,777,876,814,1459,804,1577,1578,1579,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)})},1577,[]); +__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},1578,[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})},1579,[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."})]})]})}},1580,[812,17,85,777,860,816,891,893,894,845,867,1153,804,1577,1578,1579,1581,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])},1581,[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)}`},1582,[17,85,777,876,1060,804,1577,1578,1579,1051,1581,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]})}},1583,[13,17,856,1584,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)','')}})}},1584,[1459,1585,813,912,1072,1511,1209,1210,1028,1025,1026,1512,1546,1514,1153,891,978,1586,975,880,1031,1032,1495,914,1008,915,17,1155,1241,1245,1203,356,385,278,85,409,19,777,857,876,804,1161,1419,1066,1084,1086,1081,1027,1010,1057,1505,1500,1527,1587,1427,920,219,1246,1182,1188,1457,1202,1199,1482,1185,878,1212,1213,884,776,899,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']]},1585,[17,85,777,1057,899,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}},1586,[219,976]); +__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)','')},1587,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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]})}},1588,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1589,[1452,899,778,1413,1590,995,13,1617,479,17,368,319,219,24,85,805,857,1065,856,1619,19,858,998,876,804,1427,920,988,1620,1621,1028,1104,880,1008,914,1623,1383,8,1624,1625,1626,1627]); +__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])},1590,[1591,1614,1616]); +__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)}}},1591,[198,1592,1595,1609,1610,1611,1612,1613]); +__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}},1592,[198,1593]); +__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}},1593,[1594]); +__d(function(g,r,i,a,m,e,d){},1594,[]); +__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)}},1595,[1596,198,1592,1609,1610]); +__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]}})})},1596,[1597,1598,1608]); +__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()}})}},1597,[1598,1602,1607]); +__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}}},1598,[198,355,1599,1603,1604,1605,1606,1602,1607]); +__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}},1599,[198,1600,322,263,1601,1602]); +__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])},1600,[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}}},1601,[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},1602,[]); +__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}},1603,[]); +__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}},1604,[]); +__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])},1605,[1603]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1606,[]); +__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},1607,[355,1601]); +__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])},1608,[17,1598]); +__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}},1609,[1596,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])},1610,[1596,1609]); +__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}},1611,[1592]); +__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])},1612,[198,1592,1595,1593]); +__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})({})},1613,[]); +__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]))},1614,[198,37,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 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')},1615,[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]}},1616,[17,1591]); +__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]}})})},1617,[1618]); +__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(){}},1618,[]); +__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]})}},1619,[17,24,85,409,777,857,920,899,880,805,804,1560,1562,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()})},1620,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1621,[813,779,17,974,385,85,856,899,976,804,777,1352,971,880,1622,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1622,[17,1460,385,85,899,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1623,[]); +__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"},1624,[]); +__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"},1625,[]); +__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"},1626,[]); +__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"},1627,[]); +__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]})}},1628,[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},1629,[1630]); +__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},1630,[8,1631,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}))}}},1631,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1632,[]); +__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})}}},1633,[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 77b2d32d58d86ed422a75a87e470ce767537813f..37eecb2c7a967da0f47479bf5ad19c5283725b58 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 a4f1e74b63b6230bc3a625b3ded50374ae4cfe3a..f0e0d289e27723105d98344ed16538d8b04fb816 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 ce164f5d0e4c3bf369c44a01bde6bead6b2e6e63..471cc884b9792196a0a7b47d3e7f485017428fd3 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-4321b62600"; +const V = "cc-car-69c932de50"; 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=4321b626009dd655012624e5a81d3f0f7d2a7c668ea6bb55e696c149166a28d1"]; +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=69c932de509d8a765414dcac97bc7178f5add65bd10e7c01250fd134e3cc2611"]; // 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 5b767b64f93e368f3cf112c11e00636c5705e1ec..581626f963c9b7251dd00ed613a9b23ffe4a3c2a 100644 --- a/chef-app/_expo/static/js/web/bundle.js +++ b/chef-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,1506]); +__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,1508]); __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,1502,1505]); +__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,1504,1507]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1246,1247,1252,1254,1256,1263,1315,1316,1317,1318,1319,1320,1322,1323,1324,1325,1329,1332,1333,1334,1335,1338,1412,1413,1414,1416,1457,1458,1501]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1247,1248,1253,1255,1257,1264,1316,1317,1318,1319,1320,1321,1323,1324,1325,1326,1330,1333,1334,1335,1336,1339,1414,1415,1416,1418,1459,1460,1503]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1181,1184,1187,1198,1201,1206,1208,1209,1028,884,920,1211,1156,1212,1224,1229,1238,1231,1154,1240,1244,1202,858,1152,899,1245,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1182,1185,1188,1199,1202,1207,1209,1210,1028,884,920,1212,1157,1213,1225,1230,1239,1232,1155,1241,1245,1203,858,1153,899,1246,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,371 +1222,373 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1156,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1174,[812,17,385,85,777,779,905,858,847,906,907,804,889,1175,1179,1156,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1176,[1177,928,899,856,880,1178,1038]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1177,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1178,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1179,[17,85,780,777,905,858,908,804,889,1156,1180,8]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1180,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1181,[812,1182,17,385,85,409,777,876,851,863,804,1183,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1183,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1184,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1185,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1185,[17,777,858,1186,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1186,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1187,[812,1033,1182,17,1188,219,385,409,85,1190,1191,1192,777,816,876,851,1034,804,889,1198,1183,1057,1035,1193,856,1194,1199,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1188,[17,385,85,1189,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1189,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1190,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1191,[17,85,777,812,876,851,1190,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1192,[812,1190,17,385,85,777,884,876,1071,863,804,1183,1057,1193,856,1194,1191,1195,1197,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1193,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1194,[17,85,777,876,1008,1033,1064,1062,1193,804,856,1192,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1195,[1034,1196]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1196,[1034,1190]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1197,[17,85,777,812,1033,1034,1195,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1198,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1183,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1199,[1033,17,385,85,777,812,876,1196,1034,1200,1097,804,1187,1057,1051,1190,1195,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1200,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1201,[813,876,1202,1070,1182,923,924,17,975,976,219,385,278,85,777,858,1071,1203,1192,1162,1204,1059,805,1205,1140,851,863,804,1183,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1195,1197,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1202,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1203,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1204,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1205,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1206,[17,85,777,876,804,1057,1060,1204,1071,1207,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1207,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1208,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1209,[17,219,85,1057,876,1210,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1210,[]); -__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1211,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1212,[812,1213,779,1214,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1215,1218,1221,1223,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1213,[880,805,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1214,[17,1003,876,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1215,[219,1216]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1216,[1217,856]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1217,[928,903]); -__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1218,[813,1213,1033,779,812,1214,820,876,17,319,385,85,780,777,884,1003,1004,1219,804,889,1215,1220,8]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1219,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1220,[816,876,805]); -__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1221,[17,1033,362,219,85,777,876,1003,1220,1004,1222,804,889,1214,928,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1222,[1004,991]); -__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1223,[17,85,777,804,889,992,905,858,876,1033,1222,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1224,[17,1157,1158,385,85,777,910,845,911,804,889,1225,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1225,[813,17,319,378,385,278,85,1226,777,910,845,911,863,804,1019,8,1228]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1226,[901,17,1227,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1227,[880,899]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1228,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1229,[843,1028,17,219,385,85,780,858,804,777,1230,1104,1231,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1230,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1231,[1232,1233,1235,1234,1236,1018,1237]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1232,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1233,[824,805,831,834,856,1018,1234]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1234,[843,219,856,1232]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1235,[17,858,845,853,851,1233,1232]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1236,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1237,[17,1233,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1238,[17,385,85,409,858,845,804,777,1229,1104,1239,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1239,[17,85,409,858,845,1231,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1240,[17,219,385,85,864,777,804,916,1241,1242,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1241,[856,806,928,971,916,1231,1242]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1242,[824,1243,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1243,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1244,[17,856,1241]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1245,[17,385,329,85,409,804,1189,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1246,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1247,[843,1099,861,13,17,1248,917,85,841,1249,1079,1055,777,845,851,1105,863,858,899,804,1186,848,995,998,1076,1107,1250,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1248,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1249,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1250,[17,385,85,862,863,1033,1251,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1251,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1252,[900,13,17,319,85,1226,1253,777,845,851,858,867,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1253,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1254,[13,17,777,1255,858,1240,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1255,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1256,[822,13,17,1257,777,851,858,804,1258,1262,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1257,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1258,[17,85,777,851,1259,1260,1261,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1259,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1260,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1261,[928,899,1260]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1262,[831,928,971,899,880,1259]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1263,[1264,1265,805,1266,1275,1276,1277,843,13,17,219,385,85,1226,1253,777,845,851,862,858,900,804,1278,1240,856,876,1225,910,911,920,1279,1262,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1264,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1265,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1266,[17,85,777,1267,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1267,[806,1033,1268,1270,1272,17,85,812,777,804,1269,1273,1274,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1269,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1270,[1271,1269]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1271,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1272,[1269]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1273,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1274,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1275,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1157,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1175,[812,17,385,85,777,779,905,858,847,906,907,804,889,1176,1180,1157,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1177,[1178,928,899,856,880,1179,1038]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1178,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1179,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1180,[17,85,780,777,905,858,908,804,889,1157,1181,8]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1181,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1182,[812,1183,17,385,85,409,777,876,851,863,804,1184,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1184,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1185,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1186,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1186,[17,777,858,1187,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1187,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1188,[812,1033,1183,17,1189,219,385,409,85,1191,1192,1193,777,816,876,851,1034,804,889,1199,1184,1057,1035,1194,856,1195,1200,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1189,[17,385,85,1190,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1190,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1191,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1192,[17,85,777,812,876,851,1191,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1193,[812,1191,17,385,85,777,884,876,1071,863,804,1184,1057,1194,856,1195,1192,1196,1198,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1194,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1195,[17,85,777,876,1008,1033,1064,1062,1194,804,856,1193,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1196,[1034,1197]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1197,[1034,1191]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1198,[17,85,777,812,1033,1034,1196,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1199,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1184,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1200,[1033,17,385,85,777,812,876,1197,1034,1201,1097,804,1188,1057,1051,1191,1196,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1201,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1202,[813,876,1203,1070,1183,923,924,17,975,976,219,385,278,85,777,858,1071,1204,1193,1163,1205,1059,805,1206,1140,851,863,804,1184,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1196,1198,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1203,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1204,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1205,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1206,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1207,[17,85,777,876,804,1057,1060,1205,1071,1208,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1208,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1209,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1210,[17,219,85,1057,876,1211,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1211,[]); +__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1212,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1213,[812,1214,779,1215,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1216,1219,1222,1224,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1214,[880,805,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1215,[17,1003,876,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1216,[219,1217]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1217,[1218,856]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1218,[928,903]); +__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1219,[813,1214,1033,779,812,1215,820,876,17,319,385,85,780,777,884,1003,1004,1220,804,889,1216,1221,8]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1220,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1221,[816,876,805]); +__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1222,[17,1033,362,219,85,777,876,1003,1221,1004,1223,804,889,1215,928,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1223,[1004,991]); +__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1224,[17,85,777,804,889,992,905,858,876,1033,1223,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1225,[17,1158,1159,385,85,777,910,845,911,804,889,1226,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1226,[813,17,319,378,385,278,85,1227,777,910,845,911,863,804,1019,8,1229]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1227,[901,17,1228,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1228,[880,899]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1229,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1230,[843,1028,17,219,385,85,780,858,804,777,1231,1104,1232,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1231,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1232,[1233,1234,1236,1235,1237,1018,1238]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1233,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1234,[824,805,831,834,856,1018,1235]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1235,[843,219,856,1233]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1236,[17,858,845,853,851,1234,1233]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1237,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1238,[17,1234,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1239,[17,385,85,409,858,845,804,777,1230,1104,1240,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1240,[17,85,409,858,845,1232,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1241,[17,219,385,85,864,777,804,916,1242,1243,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1242,[856,806,928,971,916,1232,1243]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1243,[824,1244,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1244,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1245,[17,856,1242]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1246,[17,385,329,85,409,804,1190,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1247,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1248,[843,1099,861,13,17,1249,917,85,841,1250,1079,1055,777,845,851,1105,863,858,899,804,1187,848,995,998,1076,1107,1251,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1249,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1250,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1251,[17,385,85,862,863,1033,1252,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1252,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1253,[900,13,17,319,85,1227,1254,777,845,851,858,867,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1254,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1255,[13,17,777,1256,858,1241,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1256,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1257,[822,13,17,1258,777,851,858,804,1259,1263,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1258,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1259,[17,85,777,851,1260,1261,1262,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1260,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1261,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1262,[928,899,1261]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1263,[831,928,971,899,880,1260]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1264,[1265,1266,805,1267,1276,1277,1278,843,13,17,219,385,85,1227,1254,777,845,851,862,858,900,804,1279,1241,856,876,1226,910,911,920,1280,1263,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1265,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1266,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1267,[17,85,777,1268,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1268,[806,1033,1269,1271,1273,17,85,812,777,804,1270,1274,1275,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1270,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1271,[1272,1270]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1272,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1273,[1270]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1274,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1275,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1276,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1277,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1278,[17,385,85,409,777,804,1189,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1279,[17,85,1280,777,858,920,1259,1262,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1280,[17,85,1281,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1281,[1282]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1282,[17,780,1283,1312,1313,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1283,[1284]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1284,[1285,1286,1309,1311]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1285,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1286,[1287,1288,1289,1290,1291,1292,1293,1294,1295,1298,1302,1299,1303]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1287,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1288,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1289,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1290,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1295,[1296]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1299,[1300,1301]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1300,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1301,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1304,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1305,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1307,[1299,1287]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1308,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1309,[1310]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1311,[1310]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1312,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1313,[17,780,1314,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1314,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1315,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1316,[822,13,17,85,1280,777,851,858,804,1279,1262,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1317,[822,13,17,85,1257,777,858,876,851,863,804,1258,1262,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1318,[822,13,17,777,858,876,863,804,1279,1262,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1319,[822,13,17,777,858,876,804,1279,1262,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1320,[13,17,777,863,1140,1321,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1321,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1322,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1323,[843,13,17,1248,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1324,[13,17,85,1253,777,845,862,858,804,1278,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1325,[13,17,1326,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1326,[17,85,777,1099,804,1327,1328,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1327,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1328,[928,971,1327]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1329,[843,13,17,85,1255,777,845,851,863,858,804,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1330,[17,354,362,219,13,777,851,804,900,1331,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1331,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1332,[843,1262,13,17,85,777,845,851,863,858,864,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]})}},1333,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1334,[822,13,17,777,858,805,1262,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1335,[13,17,777,1336,1153,1262,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1336,[812,843,17,85,777,845,851,1153,1337,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1337,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1338,[13,17,856,1339,1410,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1339,[1053,779,805,806,1340,813,1341,1094,843,1140,1342,1343,1344,1091,1122,1345,1346,1351,1352,1209,1353,856,1358,1359,1360,1115,1113,920,1361,1152,891,1104,1362,17,1072,1184,1018,1087,1363,378,363,385,278,85,409,19,777,1240,1244,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1364,1108,1365,1371,1373,1376,1381,1375,1382,1385,1386,1117,1095,1096,862,1391,1229,1392,1239,1231,995,1397,1402,1403,1054,1052,1119,1405,1406,1407,1071,1171,1408,1170,1161,853,1354,1409,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1342,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1343,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1344,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1345,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1346,[17,378,385,409,85,1280,777,1171,779,998,1347,1348,1350,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1347,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1348,[17,378,385,278,395,85,409,779,777,804,1349,1350,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1349,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1350,[993,856,1349,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1351,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1352,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1353,[1167,17,219,385,85,777,1166,804,876,920,1354,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1354,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1355,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1355,[831,928,899,1356,880,1357]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1356,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1357,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1358,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1360,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1361,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1362,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1363,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1364,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1365,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1366,1368,1367,998,876,1108,1369,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1366,[813,843,17,1367,85,842,804,777,1109,1368,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1367,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1368,[1367,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1369,[17,368,278,85,842,982,1370,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[17,219,385,85,804,777,1171,1372,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1374,804,777,1375,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1376,[805,813,17,266,319,219,385,85,409,804,857,1377,777,999,916,1351,1379,880,1380,1381,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1377,[17,219,85,1378,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1378,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1379,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1381,[17,831,928,899,1380]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1382,[843,841,998,1383,1384]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1383,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1384,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1385,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1386,[1387,843,1095,998,17,85,777,1098,858,1116,1382,1096,863,1093,1117,1118,1119,804,1343,1389,1390,1115,1360,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1387,[17,362,385,85,858,920,876,996,1388,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1388,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1391,[1171,1387,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1375,858,998,845,1089,1076,1321,804,1343,1389,1390,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1392,[812,17,219,385,85,777,858,998,1393,804,1394,1396,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1393,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1394,[831,858,998,1393,1395,1396]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1395,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1396,[219,1395]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1397,[843,17,1188,1171,385,85,995,998,862,863,804,777,1398,1401,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1398,[1399,854,843,17,264,378,385,278,85,858,995,998,1400,863,804,1026,777,1401,1355,899,1343,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1399,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1400,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1401,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1403,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1404,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1405,[843,1383]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1406,[17,385,85,777,1405,804,1363,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1407,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1408,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[17,1005,876,926,816,1006,916,1355,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[805,813,857,17,219,385,85,409,899,804,777,1351,1411,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); -__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]})}},1412,[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]})}},1413,[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,{})}},1414,[13,17,1415,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1415,[]); -__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]})}},1416,[13,17,856,1417,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)','')}})}},1417,[1418,1422,813,912,1072,1423,1208,1209,1028,1025,1026,1424,1426,1429,1152,891,978,1431,975,880,1031,1032,1432,914,1008,915,17,1154,1240,1244,1202,356,385,278,85,409,19,777,857,876,804,1160,1433,1066,1084,1086,1081,1027,1010,1057,1440,1441,1442,1450,1451,920,219,1245,1181,1187,1447,1201,1198,1456,1184,878,1211,1212,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1418,[812,17,1018,378,85,1108,1109,1365,1397,777,995,998,863,804,1057,999,1419,1420,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1419,[812,17,385,85,777,804,998,805,999,856,899,8]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1420,[17,85,777,998,1421,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1421,[]); -__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']]},1422,[17,85,777,1057,899,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)},1423,[843,17,85,777,845,851,1153,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)}}})]})}},1424,[899,17,264,219,85,1280,777,1259,1262,804,1425,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},1425,[17,219,85,777,1259,8]); -__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}},1426,[17,779,85,777,845,1259,1427,1428,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'},1427,[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()})},1428,[899,1427,1262]); -__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'})})}},1429,[805,1430,17,85,777,851,1259,1260,1261,899,1262,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1430,[]); -__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}},1431,[219,976]); -__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]},1432,[17,85,777,804,914,1022,899,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1433,[805,1430,1095,1269,1434,812,822,1117,1118,1091,1122,1435,1114,1119,1405,1406,1057,1343,996,1120,1089,841,1384,1125,1437,1240,1438,1397,1078,1055,1090,17,85,777,1363,858,845,851,863,1321,804,1183,1098,1115,998,1360,1062,1161,1439,1231,899,1185,1402,862,8]); -__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])},1434,[806,17,85,777,899,1273,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1435,[17,385,85,1436,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1436,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1437,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1186,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1438,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1439,[17,85,864,858,848,804,777,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])},1440,[17,1398,1057,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])},1441,[843,17,85,1161,777,858,845,853,863,804,1183,1057,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})},1442,[820,896,1443,17,219,85,777,816,876,895,1000,897,899,1449,804,880,1162,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1443,[812,891,1140,899,780,1229,1231,17,264,362,219,385,85,409,864,777,858,1240,876,851,863,804,1183,1057,853,1055,1444,1160,1447,1448,1139,1145,1144,1008,839,1142,1148,1220,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1444,[886,779,816,813,822,862,1039,1445,17,909,319,362,219,385,85,777,858,876,863,804,1183,1057,1220,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1445,[482,1446]); -__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}});var t={}},1446,[]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1447,[812,17,1227,1026,854,362,385,85,777,876,851,863,804,1183,1057,1220,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1448,[978,17,385,85,777,876,804,1057,1160,899,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'}},1449,[]); -__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)','')},1450,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1451,[1452,17,219,24,85,856,1453,920,804,1455,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1452,[]); -__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])},1453,[17,278,85,777,857,804,1454,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(' ')},1454,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1455,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1456,[1184,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1181,1444,1161,860,1185,853,1183,884,1360,998,843,1115,1198,1205,1071,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]})}},1457,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1458,[1459,899,778,1411,1461,995,13,1488,479,17,368,319,219,24,85,805,857,1065,856,1490,19,858,998,876,804,1451,920,988,1493,1494,1028,1104,880,1008,914,1496,1381,8,1497,1498,1499,1500]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1459,[880,812,17,219,366,85,777,1460,899,804,1187,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1460,[]); -__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])},1461,[1462,1485,1487]); -__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)}}},1462,[198,1463,1466,1480,1481,1482,1483,1484]); -__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}},1463,[198,1464]); -__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}},1464,[1465]); -__d(function(g,r,i,a,m,e,d){},1465,[]); -__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)}},1466,[1467,198,1463,1480,1481]); -__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]}})})},1467,[1468,1469,1479]); -__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()}})}},1468,[1469,1473,1478]); -__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}}},1469,[198,355,1470,1474,1475,1476,1477,1473,1478]); -__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}},1470,[198,1471,322,263,1472,1473]); -__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])},1471,[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}}},1472,[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},1473,[]); -__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}},1474,[]); -__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}},1475,[]); -__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])},1476,[1474]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1477,[]); -__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},1478,[355,1472]); -__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])},1479,[17,1469]); -__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}},1480,[1467,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])},1481,[1467,1480]); -__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}},1482,[1463]); -__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])},1483,[198,1463,1466,1464]); -__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})({})},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}),_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]))},1485,[198,37,1486]); -__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')},1486,[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]}},1487,[17,1462]); -__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]}})})},1488,[1489]); -__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(){}},1489,[]); -__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]})}},1490,[17,24,85,409,777,857,920,899,880,805,804,1491,1492,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1491,[]); -__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])},1492,[17,85,777,804,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()})},1493,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1494,[813,779,17,974,385,85,856,899,976,804,777,1351,971,880,1495,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1495,[17,1419,385,85,899,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1496,[]); -__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1497,[]); -__d(function(e,o,s,p,c,t,d){"use strict";c.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1498,[]); -__d(function(o,e,s,p,f,t,d){"use strict";f.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1499,[]); -__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1500,[]); -__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]})}},1501,[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},1502,[1503]); -__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},1503,[8,1504,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}))}}},1504,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1505,[]); -__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})}}},1506,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1278,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1279,[17,385,85,409,777,804,1190,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1280,[17,85,1281,777,858,920,1260,1263,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1281,[17,85,1282,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1282,[1283]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1283,[17,780,1284,1313,1314,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1284,[1285]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1285,[1286,1287,1310,1312]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1286,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1287,[1288,1289,1290,1291,1292,1293,1294,1295,1296,1299,1303,1300,1304]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1288,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1289,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1290,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1291,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1296,[1297]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1300,[1301,1302]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1301,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1302,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1305,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1306,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1308,[1300,1288]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1309,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1310,[1311]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1312,[1311]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1313,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1314,[17,780,1315,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1315,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1316,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1317,[822,13,17,85,1281,777,851,858,804,1280,1263,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1318,[822,13,17,85,1258,777,858,876,851,863,804,1259,1263,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1319,[822,13,17,777,858,876,863,804,1280,1263,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1320,[822,13,17,777,858,876,804,1280,1263,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1321,[13,17,777,863,1140,1322,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1322,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1323,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1324,[843,13,17,1249,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1325,[13,17,85,1254,777,845,862,858,804,1279,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1326,[13,17,1327,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1327,[17,85,777,1099,804,1328,1329,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1328,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1329,[928,971,1328]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1330,[843,13,17,85,1256,777,845,851,863,858,804,1331,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1331,[17,354,362,219,13,777,851,804,900,1332,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1332,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1333,[843,1263,13,17,85,777,845,851,863,858,864,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]})}},1334,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1335,[822,13,17,777,858,805,1263,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1336,[13,17,777,1337,1154,1263,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1337,[812,843,17,85,777,845,851,1154,1338,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1338,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1339,[13,17,856,1340,1412,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1340,[1053,779,805,806,1341,813,1342,1094,843,1140,1343,1344,1345,1091,1122,1346,1347,1352,1353,1210,1354,856,1359,1360,1361,1115,1113,920,1362,1153,891,1104,1363,17,1072,1185,1018,1087,1364,21,378,363,385,278,85,409,19,777,1241,1245,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1365,1108,1366,1372,1374,1378,1383,1377,1384,1387,1388,1117,1095,1096,862,1393,1230,1394,1240,1232,995,1399,1404,1405,1054,1052,1119,1407,1408,1409,1071,1172,1410,1171,1162,853,1355,1411,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1343,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1344,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1345,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1346,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1347,[17,378,385,409,85,1281,777,1172,779,998,1348,1349,1351,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1348,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1349,[17,378,385,278,395,85,409,779,777,804,1350,1351,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1350,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1351,[993,856,1350,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1352,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1353,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1354,[1168,17,219,385,85,777,1167,804,876,920,1355,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1355,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1356,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1356,[831,928,899,1357,880,1358]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1357,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1358,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1359,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1361,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1362,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1363,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1364,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1365,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1366,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1367,1369,1368,998,876,1108,1370,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1367,[813,843,17,1368,85,842,804,777,1109,1369,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1368,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1369,[1368,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1370,[17,368,278,85,842,982,1371,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1371,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1372,[17,219,385,85,804,777,1172,1373,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1373,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1374,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1375,841,863,1096,1376,804,777,1377,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1375,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1376,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1377,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1378,[805,813,17,266,319,219,385,85,409,804,857,1379,777,999,916,1352,1381,880,1382,1383,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1379,[17,219,85,1380,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1380,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1381,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1383,[17,831,928,899,1382]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1384,[843,841,998,1385,1386]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1385,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1386,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1387,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1388,[1389,843,1095,998,17,85,777,1098,858,1116,1384,1096,863,1093,1117,1118,1119,804,1344,1391,1392,1115,1361,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1389,[17,362,385,85,858,920,876,996,1390,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1390,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1393,[1172,1389,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1377,858,998,845,1089,1076,1322,804,1344,1391,1392,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1394,[812,17,219,385,85,777,858,998,1395,804,1396,1398,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1395,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1396,[831,858,998,1395,1397,1398]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1397,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1398,[219,1397]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1399,[843,17,1189,1172,385,85,995,998,862,863,804,777,1400,1403,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1400,[1401,854,843,17,264,378,385,278,85,858,995,998,1402,863,804,1026,777,1403,1356,899,1344,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1401,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1402,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1403,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1405,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1406,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1407,[843,1385]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1408,[17,385,85,777,1407,804,1364,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1409,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1410,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1411,[17,1005,876,926,816,1006,916,1356,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1412,[805,813,857,17,219,385,85,409,899,804,777,1352,1413,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1413,[]); +__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]})}},1414,[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]})}},1415,[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,{})}},1416,[13,17,1417,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1417,[]); +__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]})}},1418,[13,17,856,1419,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)','')}})}},1419,[1420,1424,813,912,1072,1425,1209,1210,1028,1025,1026,1426,1428,1431,1153,891,978,1433,975,880,1031,1032,1434,914,1008,915,17,1155,1241,1245,1203,356,385,278,85,409,19,777,857,876,804,1161,1435,1066,1084,1086,1081,1027,1010,1057,1442,1443,1444,1452,1453,920,219,1246,1182,1188,1449,1202,1199,1458,1185,878,1212,1213,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1420,[812,17,1018,378,85,1108,1109,1366,1399,777,995,998,863,804,1057,999,1421,1422,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1421,[812,17,385,85,777,804,998,805,999,856,899,8]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1422,[17,85,777,998,1423,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1423,[]); +__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']]},1424,[17,85,777,1057,899,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)},1425,[843,17,85,777,845,851,1154,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)}}})]})}},1426,[899,17,264,219,85,1281,777,1260,1263,804,1427,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},1427,[17,219,85,777,1260,8]); +__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}},1428,[17,779,85,777,845,1260,1429,1430,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'},1429,[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()})},1430,[899,1429,1263]); +__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'})})}},1431,[805,1432,17,85,777,851,1260,1261,1262,899,1263,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1432,[]); +__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}},1433,[219,976]); +__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]},1434,[17,85,777,804,914,1022,899,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1435,[805,1432,1095,1270,1436,812,822,1117,1118,1091,1122,1437,1114,1119,1407,1408,1057,1344,996,1120,1089,841,1386,1125,1439,1241,1440,1399,1078,1055,1090,17,85,777,1364,858,845,851,863,1322,804,1184,1098,1115,998,1361,1062,1162,1441,1232,899,1186,1404,862,8]); +__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])},1436,[806,17,85,777,899,1274,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1437,[17,385,85,1438,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1438,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1439,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1187,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1440,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1441,[17,85,864,858,848,804,777,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])},1442,[17,1400,1057,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])},1443,[843,17,85,1162,777,858,845,853,863,804,1184,1057,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})},1444,[820,896,1445,17,219,85,777,816,876,895,1000,897,899,1451,804,880,1163,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1445,[812,891,1140,899,780,1230,1232,17,264,362,219,385,85,409,864,777,858,1241,876,851,863,804,1184,1057,853,1055,1446,1161,1449,1450,1139,1146,1145,1008,839,1142,1149,1221,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1446,[886,779,816,813,822,862,1039,1447,17,909,319,362,219,385,85,777,858,876,863,804,1184,1057,1221,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1447,[482,1448]); +__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}});var t={}},1448,[]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1449,[812,17,1228,1026,854,362,385,85,777,876,851,863,804,1184,1057,1221,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1450,[978,17,385,85,777,876,804,1057,1161,899,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'}},1451,[]); +__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)','')},1452,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1453,[1454,17,219,24,85,856,1455,920,804,1457,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1454,[]); +__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])},1455,[17,278,85,777,857,804,1456,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(' ')},1456,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1457,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1458,[1185,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1182,1446,1162,860,1186,853,1184,884,1361,998,843,1115,1199,1206,1071,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]})}},1459,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1460,[1461,899,778,1413,1463,995,13,1490,479,17,368,319,219,24,85,805,857,1065,856,1492,19,858,998,876,804,1453,920,988,1495,1496,1028,1104,880,1008,914,1498,1383,8,1499,1500,1501,1502]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1461,[880,812,17,219,366,85,777,1462,899,804,1188,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1462,[]); +__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])},1463,[1464,1487,1489]); +__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)}}},1464,[198,1465,1468,1482,1483,1484,1485,1486]); +__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}},1465,[198,1466]); +__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}},1466,[1467]); +__d(function(g,r,i,a,m,e,d){},1467,[]); +__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)}},1468,[1469,198,1465,1482,1483]); +__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]}})})},1469,[1470,1471,1481]); +__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()}})}},1470,[1471,1475,1480]); +__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}}},1471,[198,355,1472,1476,1477,1478,1479,1475,1480]); +__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}},1472,[198,1473,322,263,1474,1475]); +__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])},1473,[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}}},1474,[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},1475,[]); +__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}},1476,[]); +__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}},1477,[]); +__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])},1478,[1476]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},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,"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},1480,[355,1474]); +__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])},1481,[17,1471]); +__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}},1482,[1469,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])},1483,[1469,1482]); +__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}},1484,[1465]); +__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])},1485,[198,1465,1468,1466]); +__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})({})},1486,[]); +__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]))},1487,[198,37,1488]); +__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')},1488,[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]}},1489,[17,1464]); +__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]}})})},1490,[1491]); +__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(){}},1491,[]); +__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]})}},1492,[17,24,85,409,777,857,920,899,880,805,804,1493,1494,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1493,[]); +__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])},1494,[17,85,777,804,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()})},1495,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1496,[813,779,17,974,385,85,856,899,976,804,777,1352,971,880,1497,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1497,[17,1421,385,85,899,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1498,[]); +__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1499,[]); +__d(function(e,o,s,p,c,t,d){"use strict";c.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1500,[]); +__d(function(o,e,s,p,f,t,d){"use strict";f.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1501,[]); +__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1502,[]); +__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]})}},1503,[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},1504,[1505]); +__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},1505,[8,1506,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}))}}},1506,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1507,[]); +__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})}}},1508,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/chef-app/admin.html b/chef-app/admin.html index eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 59ec9eb3042cacf87b5ae298faad4f5a86090ec1..c2494a493108bd50fab8b6d21caf0058daf5a29d 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 b1ee4a5e4301e759330e8b0254b45a16d95f331f..0dc5cbb7e1fe7612f7cc2472ed7cdcee083664f5 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-05a264acc7"; +const V = "cc-chef-506bde956c"; 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=05a264acc70b318f19a59a43fe0fbe3142da6c304e6f243493be53af4e8b924a"]; +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=506bde956c85068535214c18d879b4b8779e60b41c4195745eae08007bd7c403"]; // 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 eaf5f25a28dd80cd80775d07585782d06e662990..d04491524030e739dbd236f6e4ed125ca1e6f7a9 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 afc45d5dc1f714c4e334a7fbeb06d347cc4629e3..aac5e00890cb22b1005a1d2a6aced17620b5e5db 100644 --- a/customer-app/_expo/static/js/web/bundle.js +++ b/customer-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,1490]); +__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,1492]); __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,1486,1489]); +__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,1488,1491]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1225,1226,1231,1235,1237,1244,1298,1299,1300,1301,1302,1303,1305,1306,1307,1308,1312,1315,1316,1317,1318,1321,1395,1396,1397,1399,1441,1442,1485]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1226,1227,1232,1236,1238,1245,1299,1300,1301,1302,1303,1304,1306,1307,1308,1309,1313,1316,1317,1318,1319,1322,1397,1398,1399,1401,1443,1444,1487]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1175,1178,1181,1192,1195,1200,1202,1203,1028,884,920,1205,1156,1206,1207,1208,1217,1210,1154,1219,1223,1196,858,1152,899,1224,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1176,1179,1182,1193,1196,1201,1203,1204,1028,884,920,1206,1157,1207,1208,1209,1218,1211,1155,1220,1224,1197,858,1153,899,1225,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,355 +1222,357 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1156,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,840,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1174,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1175,[812,1176,17,385,85,409,777,876,851,863,804,1177,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1177,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1178,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1179,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1179,[17,777,858,1180,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1180,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1181,[812,1033,1176,17,1182,219,385,409,85,1184,1185,1186,777,816,876,851,1034,804,889,1192,1177,1057,1035,1187,856,1188,1193,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1182,[17,385,85,1183,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1183,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1184,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1185,[17,85,777,812,876,851,1184,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1186,[812,1184,17,385,85,777,884,876,1071,863,804,1177,1057,1187,856,1188,1185,1189,1191,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1187,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1188,[17,85,777,876,1008,1033,1064,1062,1187,804,856,1186,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1189,[1034,1190]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1190,[1034,1184]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1191,[17,85,777,812,1033,1034,1189,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1192,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1177,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1193,[1033,17,385,85,777,812,876,1190,1034,1194,1097,804,1181,1057,1051,1184,1189,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1194,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1195,[813,876,1196,1070,1176,923,924,17,975,976,219,385,278,85,777,858,1071,1197,1186,1162,1198,1059,805,1199,1140,851,863,804,1177,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1189,1191,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1196,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1197,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1198,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1199,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1200,[17,85,777,876,804,1057,1060,1198,1071,1201,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1201,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1202,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1203,[17,219,85,1057,876,1204,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1204,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1205,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1206,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1207,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1208,[843,1028,17,219,385,85,780,858,804,777,1209,1104,1210,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1209,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1210,[1211,1212,1214,1213,1215,1018,1216]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1211,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1212,[824,805,831,834,856,1018,1213]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1213,[843,219,856,1211]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1214,[17,858,845,853,851,1212,1211]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1215,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1216,[17,1212,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1217,[17,385,85,409,858,845,804,777,1208,1104,1218,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1218,[17,85,409,858,845,1210,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1219,[17,219,385,85,864,777,804,916,1220,1221,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1220,[856,806,928,971,916,1210,1221]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1221,[824,1222,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1222,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1223,[17,856,1220]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1224,[17,385,329,85,409,804,1183,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1225,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1226,[843,1099,861,13,17,1227,917,85,841,1228,1079,1055,777,845,851,1105,863,858,899,804,1180,848,995,998,1076,1107,1229,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1227,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1228,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1229,[17,385,85,862,863,1033,1230,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1230,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1231,[900,13,17,319,85,1232,1234,777,845,851,858,867,804,8]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1232,[901,17,1233,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1233,[880,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1234,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1235,[13,17,777,1236,858,1219,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1236,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1237,[822,13,17,1238,777,851,858,804,1239,1243,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1238,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1239,[17,85,777,851,1240,1241,1242,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1240,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1241,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1242,[928,899,1241]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1243,[831,928,971,899,880,1240]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1244,[1245,1246,805,1247,1256,1257,1258,843,13,17,219,385,85,1232,1234,777,845,851,862,858,900,804,1259,1219,856,876,1260,910,911,920,1262,1243,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1245,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1246,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1247,[17,85,777,1248,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1248,[806,1033,1249,1251,1253,17,85,812,777,804,1250,1254,1255,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1250,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1251,[1252,1250]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1252,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1253,[1250]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1254,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1255,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1256,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1157,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,840,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1175,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1176,[812,1177,17,385,85,409,777,876,851,863,804,1178,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1178,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1179,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1180,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1180,[17,777,858,1181,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1181,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1182,[812,1033,1177,17,1183,219,385,409,85,1185,1186,1187,777,816,876,851,1034,804,889,1193,1178,1057,1035,1188,856,1189,1194,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1183,[17,385,85,1184,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1184,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1185,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1186,[17,85,777,812,876,851,1185,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1187,[812,1185,17,385,85,777,884,876,1071,863,804,1178,1057,1188,856,1189,1186,1190,1192,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1188,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1189,[17,85,777,876,1008,1033,1064,1062,1188,804,856,1187,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1190,[1034,1191]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1191,[1034,1185]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1192,[17,85,777,812,1033,1034,1190,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1193,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1178,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1194,[1033,17,385,85,777,812,876,1191,1034,1195,1097,804,1182,1057,1051,1185,1190,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1195,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1196,[813,876,1197,1070,1177,923,924,17,975,976,219,385,278,85,777,858,1071,1198,1187,1163,1199,1059,805,1200,1140,851,863,804,1178,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1190,1192,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1197,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1198,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1199,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1200,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1201,[17,85,777,876,804,1057,1060,1199,1071,1202,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1202,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1203,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1204,[17,219,85,1057,876,1205,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1205,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1206,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1207,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1208,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1209,[843,1028,17,219,385,85,780,858,804,777,1210,1104,1211,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1210,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1211,[1212,1213,1215,1214,1216,1018,1217]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1212,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1213,[824,805,831,834,856,1018,1214]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1214,[843,219,856,1212]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1215,[17,858,845,853,851,1213,1212]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1216,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1217,[17,1213,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1218,[17,385,85,409,858,845,804,777,1209,1104,1219,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1219,[17,85,409,858,845,1211,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1220,[17,219,385,85,864,777,804,916,1221,1222,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1221,[856,806,928,971,916,1211,1222]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1222,[824,1223,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1223,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1224,[17,856,1221]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1225,[17,385,329,85,409,804,1184,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1226,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1227,[843,1099,861,13,17,1228,917,85,841,1229,1079,1055,777,845,851,1105,863,858,899,804,1181,848,995,998,1076,1107,1230,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1228,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1229,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1230,[17,385,85,862,863,1033,1231,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1231,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1232,[900,13,17,319,85,1233,1235,777,845,851,858,867,804,8]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1233,[901,17,1234,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1234,[880,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1235,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1236,[13,17,777,1237,858,1220,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1237,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1238,[822,13,17,1239,777,851,858,804,1240,1244,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1239,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1240,[17,85,777,851,1241,1242,1243,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1241,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1242,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1243,[928,899,1242]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1244,[831,928,971,899,880,1241]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1245,[1246,1247,805,1248,1257,1258,1259,843,13,17,219,385,85,1233,1235,777,845,851,862,858,900,804,1260,1220,856,876,1261,910,911,920,1263,1244,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1246,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1247,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1248,[17,85,777,1249,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1249,[806,1033,1250,1252,1254,17,85,812,777,804,1251,1255,1256,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1251,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1252,[1253,1251]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1253,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1254,[1251]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1255,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1256,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1257,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1258,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1259,[17,385,85,409,777,804,1183,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1260,[813,17,319,378,385,278,85,1232,777,910,845,911,863,804,1019,8,1261]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1261,[]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1262,[17,85,1263,777,858,920,1240,1243,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1263,[17,85,1264,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1264,[1265]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1265,[17,780,1266,1295,1296,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1266,[1267]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1267,[1268,1269,1292,1294]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1268,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1269,[1270,1271,1272,1273,1274,1275,1276,1277,1278,1281,1285,1282,1286]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1270,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1271,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1272,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1273,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1278,[1279]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1282,[1283,1284]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1283,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1284,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1287,[1282]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1288,[1282]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1290,[1282,1270]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1291,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1292,[1293]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1294,[1293]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1295,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1296,[17,780,1297,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1297,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1298,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1299,[822,13,17,85,1263,777,851,858,804,1262,1243,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1300,[822,13,17,85,1238,777,858,876,851,863,804,1239,1243,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1301,[822,13,17,777,858,876,863,804,1262,1243,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1302,[822,13,17,777,858,876,804,1262,1243,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1303,[13,17,777,863,1140,1304,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1304,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1305,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1306,[843,13,17,1227,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1307,[13,17,85,1234,777,845,862,858,804,1259,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1308,[13,17,1309,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1309,[17,85,777,1099,804,1310,1311,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1310,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1311,[928,971,1310]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1312,[843,13,17,85,1236,777,845,851,863,858,804,1313,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1313,[17,354,362,219,13,777,851,804,900,1314,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1314,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1315,[843,1243,13,17,85,777,845,851,863,858,864,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]})}},1316,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1317,[822,13,17,777,858,805,1243,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1318,[13,17,777,1319,1153,1243,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1319,[812,843,17,85,777,845,851,1153,1320,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1320,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1321,[13,17,856,1322,1393,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1322,[1053,779,805,806,1323,813,1324,1094,843,1140,1325,1326,1327,1091,1122,1328,1329,1334,1335,1203,1336,856,1341,1342,1343,1115,1113,920,1344,1152,891,1104,1345,17,1072,1178,1018,1087,1346,378,363,385,278,85,409,19,777,1219,1223,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1347,1108,1348,1354,1356,1359,1364,1358,1365,1368,1369,1117,1095,1096,862,1374,1208,1375,1218,1210,995,1380,1385,1386,1054,1052,1119,1388,1389,1390,1071,1171,1391,1170,1161,853,1337,1392,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1325,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1326,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1327,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1328,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1329,[17,378,385,409,85,1263,777,1171,779,998,1330,1331,1333,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1330,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1331,[17,378,385,278,395,85,409,779,777,804,1332,1333,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1332,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1333,[993,856,1332,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1334,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1335,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1336,[1167,17,219,385,85,777,1166,804,876,920,1337,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1337,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1338,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1338,[831,928,899,1339,880,1340]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1339,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1340,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1341,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1343,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1344,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1345,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1346,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1347,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1348,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1349,1351,1350,998,876,1108,1352,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1349,[813,843,17,1350,85,842,804,777,1109,1351,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1350,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1351,[1350,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1352,[17,368,278,85,842,982,1353,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1353,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1354,[17,219,385,85,804,777,1171,1355,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1355,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1356,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1357,804,777,1358,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1357,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1358,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1359,[805,813,17,266,319,219,385,85,409,804,857,1360,777,999,916,1334,1362,880,1363,1364,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1360,[17,219,85,1361,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1361,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1362,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1364,[17,831,928,899,1363]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1365,[843,841,998,1366,1367]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1366,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1367,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1368,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1369,[1370,843,1095,998,17,85,777,1098,858,1116,1365,1096,863,1093,1117,1118,1119,804,1326,1372,1373,1115,1343,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1370,[17,362,385,85,858,920,876,996,1371,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1371,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1374,[1171,1370,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1358,858,998,845,1089,1076,1304,804,1326,1372,1373,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1375,[812,17,219,385,85,777,858,998,1376,804,1377,1379,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1376,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1377,[831,858,998,1376,1378,1379]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1378,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1379,[219,1378]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1380,[843,17,1182,1171,385,85,995,998,862,863,804,777,1381,1384,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1381,[1382,854,843,17,264,378,385,278,85,858,995,998,1383,863,804,1026,777,1384,1338,899,1326,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1382,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1383,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1384,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1386,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1387,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1388,[843,1366]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1389,[17,385,85,777,1388,804,1346,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1390,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1391,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1392,[17,1005,876,926,816,1006,916,1338,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1393,[805,813,857,17,219,385,85,409,899,804,777,1334,1394,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1394,[]); -__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]})}},1395,[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]})}},1396,[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,{})}},1397,[13,17,1398,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1398,[]); -__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]})}},1399,[13,17,856,1400,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)','')}})}},1400,[1401,1405,813,912,1072,1406,1202,1203,1028,1025,1026,1407,1409,1412,1152,891,978,1414,975,880,1031,1032,1415,914,1008,915,17,1154,1219,1223,1196,356,385,278,85,409,19,777,857,876,804,1160,1416,1066,1084,1086,1081,1027,1010,1057,1423,1424,1425,1434,1435,920,219,1224,1175,1181,1431,1195,1192,1440,1178,878,1205,1206,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1401,[812,17,1018,378,85,1108,1109,1348,1380,777,995,998,863,804,1057,999,1402,1403,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1402,[812,17,385,85,777,804,998,805,999,856,899,8]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1403,[17,85,777,998,1404,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1404,[]); -__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']]},1405,[17,85,777,1057,899,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)},1406,[843,17,85,777,845,851,1153,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)}}})]})}},1407,[899,17,264,219,85,1263,777,1240,1243,804,1408,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},1408,[17,219,85,777,1240,8]); -__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}},1409,[17,779,85,777,845,1240,1410,1411,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'},1410,[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()})},1411,[899,1410,1243]); -__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'})})}},1412,[805,1413,17,85,777,851,1240,1241,1242,899,1243,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1413,[]); -__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}},1414,[219,976]); -__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]},1415,[17,85,777,804,914,1022,899,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1416,[805,1413,1095,1250,1417,812,822,1117,1118,1091,1122,1418,1114,1119,1388,1389,1057,1326,996,1120,1089,841,1367,1125,1420,1219,1421,1380,1078,1055,1090,17,85,777,1346,858,845,851,863,1304,804,1177,1098,1115,998,1343,1062,1161,1422,1210,899,1179,1385,862,8]); -__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])},1417,[806,17,85,777,899,1254,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1418,[17,385,85,1419,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1419,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1420,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1180,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1421,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1422,[17,85,864,858,848,804,777,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])},1423,[17,1381,1057,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])},1424,[843,17,85,1161,777,858,845,853,863,804,1177,1057,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})},1425,[820,896,1426,17,219,85,777,816,876,895,1000,897,899,1433,804,880,1162,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1426,[812,891,1140,899,780,1208,1210,17,264,362,219,385,85,409,864,777,858,1219,876,851,863,804,1177,1057,853,1055,1427,1160,1431,1432,1139,1145,1144,1008,839,1142,1148,1430,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1427,[886,779,816,813,822,862,1039,1428,17,909,319,362,219,385,85,777,858,876,863,804,1177,1057,1430,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1428,[482,1429]); -__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}});var t={}},1429,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1430,[816,876,805]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1431,[812,17,1233,1026,854,362,385,85,777,876,851,863,804,1177,1057,1430,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1432,[978,17,385,85,777,876,804,1057,1160,899,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'}},1433,[]); -__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)','')},1434,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1435,[1436,17,219,24,85,856,1437,920,804,1439,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1436,[]); -__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])},1437,[17,278,85,777,857,804,1438,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(' ')},1438,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1439,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1440,[1178,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1175,1427,1161,860,1179,853,1177,884,1343,998,843,1115,1192,1199,1071,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]})}},1441,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1442,[1443,899,778,1394,1445,995,13,1472,479,17,368,319,219,24,85,805,857,1065,856,1474,19,858,998,876,804,1435,920,988,1477,1478,1028,1104,880,1008,914,1480,1364,8,1481,1482,1483,1484]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1443,[880,812,17,219,366,85,777,1444,899,804,1181,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1444,[]); -__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])},1445,[1446,1469,1471]); -__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)}}},1446,[198,1447,1450,1464,1465,1466,1467,1468]); -__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}},1447,[198,1448]); -__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}},1448,[1449]); -__d(function(g,r,i,a,m,e,d){},1449,[]); -__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)}},1450,[1451,198,1447,1464,1465]); -__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]}})})},1451,[1452,1453,1463]); -__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()}})}},1452,[1453,1457,1462]); -__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}}},1453,[198,355,1454,1458,1459,1460,1461,1457,1462]); -__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}},1454,[198,1455,322,263,1456,1457]); -__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])},1455,[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}}},1456,[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},1457,[]); -__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}},1458,[]); -__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}},1459,[]); -__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])},1460,[1458]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},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,"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},1462,[355,1456]); -__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])},1463,[17,1453]); -__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}},1464,[1451,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])},1465,[1451,1464]); -__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}},1466,[1447]); -__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])},1467,[198,1447,1450,1448]); -__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})({})},1468,[]); -__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]))},1469,[198,37,1470]); -__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')},1470,[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]}},1471,[17,1446]); -__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]}})})},1472,[1473]); -__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(){}},1473,[]); -__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]})}},1474,[17,24,85,409,777,857,920,899,880,805,804,1475,1476,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1475,[]); -__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])},1476,[17,85,777,804,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()})},1477,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1478,[813,779,17,974,385,85,856,899,976,804,777,1334,971,880,1479,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1479,[17,1402,385,85,899,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1480,[]); -__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1481,[]); -__d(function(o,s,e,p,t,c,d){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1482,[]); -__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1483,[]); -__d(function(o,s,e,p,t,d,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1484,[]); -__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]})}},1485,[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},1486,[1487]); -__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},1487,[8,1488,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}))}}},1488,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1489,[]); -__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})}}},1490,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1259,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1260,[17,385,85,409,777,804,1184,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1261,[813,17,319,378,385,278,85,1233,777,910,845,911,863,804,1019,8,1262]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1262,[]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1263,[17,85,1264,777,858,920,1241,1244,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1264,[17,85,1265,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1265,[1266]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1266,[17,780,1267,1296,1297,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1267,[1268]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1268,[1269,1270,1293,1295]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1269,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1270,[1271,1272,1273,1274,1275,1276,1277,1278,1279,1282,1286,1283,1287]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1271,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1272,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1273,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1274,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1279,[1280]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1283,[1284,1285]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1284,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1285,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1288,[1283]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1289,[1283]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1291,[1283,1271]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1292,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1293,[1294]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1295,[1294]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1296,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1297,[17,780,1298,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1298,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1299,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1300,[822,13,17,85,1264,777,851,858,804,1263,1244,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1301,[822,13,17,85,1239,777,858,876,851,863,804,1240,1244,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1302,[822,13,17,777,858,876,863,804,1263,1244,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1303,[822,13,17,777,858,876,804,1263,1244,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1304,[13,17,777,863,1140,1305,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1305,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1306,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1307,[843,13,17,1228,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1308,[13,17,85,1235,777,845,862,858,804,1260,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1309,[13,17,1310,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1310,[17,85,777,1099,804,1311,1312,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1311,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1312,[928,971,1311]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1313,[843,13,17,85,1237,777,845,851,863,858,804,1314,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1314,[17,354,362,219,13,777,851,804,900,1315,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1315,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1316,[843,1244,13,17,85,777,845,851,863,858,864,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]})}},1317,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1318,[822,13,17,777,858,805,1244,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1319,[13,17,777,1320,1154,1244,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1320,[812,843,17,85,777,845,851,1154,1321,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1321,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1322,[13,17,856,1323,1395,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1323,[1053,779,805,806,1324,813,1325,1094,843,1140,1326,1327,1328,1091,1122,1329,1330,1335,1336,1204,1337,856,1342,1343,1344,1115,1113,920,1345,1153,891,1104,1346,17,1072,1179,1018,1087,1347,21,378,363,385,278,85,409,19,777,1220,1224,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1348,1108,1349,1355,1357,1361,1366,1360,1367,1370,1371,1117,1095,1096,862,1376,1209,1377,1219,1211,995,1382,1387,1388,1054,1052,1119,1390,1391,1392,1071,1172,1393,1171,1162,853,1338,1394,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1326,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1327,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1328,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1329,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1330,[17,378,385,409,85,1264,777,1172,779,998,1331,1332,1334,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1331,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1332,[17,378,385,278,395,85,409,779,777,804,1333,1334,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1333,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1334,[993,856,1333,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1335,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1336,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1337,[1168,17,219,385,85,777,1167,804,876,920,1338,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1338,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1339,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1339,[831,928,899,1340,880,1341]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1340,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1341,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1342,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1344,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1345,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1346,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1347,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1348,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1349,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1350,1352,1351,998,876,1108,1353,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1350,[813,843,17,1351,85,842,804,777,1109,1352,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1351,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1352,[1351,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1353,[17,368,278,85,842,982,1354,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1354,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1355,[17,219,385,85,804,777,1172,1356,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1356,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1357,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1358,841,863,1096,1359,804,777,1360,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1358,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1359,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1360,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1361,[805,813,17,266,319,219,385,85,409,804,857,1362,777,999,916,1335,1364,880,1365,1366,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1362,[17,219,85,1363,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1363,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1364,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1366,[17,831,928,899,1365]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1367,[843,841,998,1368,1369]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1368,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1369,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1370,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1371,[1372,843,1095,998,17,85,777,1098,858,1116,1367,1096,863,1093,1117,1118,1119,804,1327,1374,1375,1115,1344,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1372,[17,362,385,85,858,920,876,996,1373,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1373,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1376,[1172,1372,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1360,858,998,845,1089,1076,1305,804,1327,1374,1375,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1377,[812,17,219,385,85,777,858,998,1378,804,1379,1381,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1378,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1379,[831,858,998,1378,1380,1381]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1380,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1381,[219,1380]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1382,[843,17,1183,1172,385,85,995,998,862,863,804,777,1383,1386,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1383,[1384,854,843,17,264,378,385,278,85,858,995,998,1385,863,804,1026,777,1386,1339,899,1327,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1384,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1385,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1386,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1388,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1389,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1390,[843,1368]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1391,[17,385,85,777,1390,804,1347,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1392,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1393,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1394,[17,1005,876,926,816,1006,916,1339,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1395,[805,813,857,17,219,385,85,409,899,804,777,1335,1396,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1396,[]); +__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]})}},1397,[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]})}},1398,[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,{})}},1399,[13,17,1400,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1400,[]); +__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]})}},1401,[13,17,856,1402,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)','')}})}},1402,[1403,1407,813,912,1072,1408,1203,1204,1028,1025,1026,1409,1411,1414,1153,891,978,1416,975,880,1031,1032,1417,914,1008,915,17,1155,1220,1224,1197,356,385,278,85,409,19,777,857,876,804,1161,1418,1066,1084,1086,1081,1027,1010,1057,1425,1426,1427,1436,1437,920,219,1225,1176,1182,1433,1196,1193,1442,1179,878,1206,1207,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1403,[812,17,1018,378,85,1108,1109,1349,1382,777,995,998,863,804,1057,999,1404,1405,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1404,[812,17,385,85,777,804,998,805,999,856,899,8]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1405,[17,85,777,998,1406,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1406,[]); +__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']]},1407,[17,85,777,1057,899,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)},1408,[843,17,85,777,845,851,1154,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)}}})]})}},1409,[899,17,264,219,85,1264,777,1241,1244,804,1410,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},1410,[17,219,85,777,1241,8]); +__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}},1411,[17,779,85,777,845,1241,1412,1413,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'},1412,[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()})},1413,[899,1412,1244]); +__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'})})}},1414,[805,1415,17,85,777,851,1241,1242,1243,899,1244,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1415,[]); +__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}},1416,[219,976]); +__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]},1417,[17,85,777,804,914,1022,899,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1418,[805,1415,1095,1251,1419,812,822,1117,1118,1091,1122,1420,1114,1119,1390,1391,1057,1327,996,1120,1089,841,1369,1125,1422,1220,1423,1382,1078,1055,1090,17,85,777,1347,858,845,851,863,1305,804,1178,1098,1115,998,1344,1062,1162,1424,1211,899,1180,1387,862,8]); +__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])},1419,[806,17,85,777,899,1255,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[17,385,85,1421,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1181,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1424,[17,85,864,858,848,804,777,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])},1425,[17,1383,1057,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])},1426,[843,17,85,1162,777,858,845,853,863,804,1178,1057,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})},1427,[820,896,1428,17,219,85,777,816,876,895,1000,897,899,1435,804,880,1163,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1428,[812,891,1140,899,780,1209,1211,17,264,362,219,385,85,409,864,777,858,1220,876,851,863,804,1178,1057,853,1055,1429,1161,1433,1434,1139,1146,1145,1008,839,1142,1149,1432,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1429,[886,779,816,813,822,862,1039,1430,17,909,319,362,219,385,85,777,858,876,863,804,1178,1057,1432,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1430,[482,1431]); +__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}});var t={}},1431,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1432,[816,876,805]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1433,[812,17,1234,1026,854,362,385,85,777,876,851,863,804,1178,1057,1432,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1434,[978,17,385,85,777,876,804,1057,1161,899,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'}},1435,[]); +__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)','')},1436,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1437,[1438,17,219,24,85,856,1439,920,804,1441,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1438,[]); +__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])},1439,[17,278,85,777,857,804,1440,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(' ')},1440,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1441,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1442,[1179,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1176,1429,1162,860,1180,853,1178,884,1344,998,843,1115,1193,1200,1071,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]})}},1443,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1444,[1445,899,778,1396,1447,995,13,1474,479,17,368,319,219,24,85,805,857,1065,856,1476,19,858,998,876,804,1437,920,988,1479,1480,1028,1104,880,1008,914,1482,1366,8,1483,1484,1485,1486]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1445,[880,812,17,219,366,85,777,1446,899,804,1182,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1446,[]); +__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])},1447,[1448,1471,1473]); +__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)}}},1448,[198,1449,1452,1466,1467,1468,1469,1470]); +__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}},1449,[198,1450]); +__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}},1450,[1451]); +__d(function(g,r,i,a,m,e,d){},1451,[]); +__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)}},1452,[1453,198,1449,1466,1467]); +__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]}})})},1453,[1454,1455,1465]); +__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()}})}},1454,[1455,1459,1464]); +__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}}},1455,[198,355,1456,1460,1461,1462,1463,1459,1464]); +__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}},1456,[198,1457,322,263,1458,1459]); +__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])},1457,[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}}},1458,[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},1459,[]); +__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}},1460,[]); +__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}},1461,[]); +__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])},1462,[1460]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1463,[]); +__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},1464,[355,1458]); +__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])},1465,[17,1455]); +__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}},1466,[1453,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])},1467,[1453,1466]); +__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}},1468,[1449]); +__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])},1469,[198,1449,1452,1450]); +__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})({})},1470,[]); +__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]))},1471,[198,37,1472]); +__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')},1472,[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]}},1473,[17,1448]); +__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]}})})},1474,[1475]); +__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(){}},1475,[]); +__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]})}},1476,[17,24,85,409,777,857,920,899,880,805,804,1477,1478,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1477,[]); +__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])},1478,[17,85,777,804,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()})},1479,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1480,[813,779,17,974,385,85,856,899,976,804,777,1335,971,880,1481,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1481,[17,1404,385,85,899,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1482,[]); +__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1483,[]); +__d(function(o,s,e,p,t,c,d){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1484,[]); +__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1485,[]); +__d(function(o,s,e,p,t,d,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1486,[]); +__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]})}},1487,[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},1488,[1489]); +__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},1489,[8,1490,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}))}}},1490,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1491,[]); +__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})}}},1492,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/customer-app/admin.html b/customer-app/admin.html index cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 468ae22d462a629270418ab6c0a032a3eb781b3d..426d0a6afe964815ed0bbdc934c827f1408dca7e 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 250bd6627c0c00ea0587842a124af1e85ea24b95..e3995a922b72ebb3db264c953e9932f6b4a3735b 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-99cefad6a7"; +const V = "cc-customer-6530b70e8a"; 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=99cefad6a783aad8a81eca79246985c7e75094761f649bb257b6f88296abdb3e"]; +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=6530b70e8ae6d76373041f1ca015fea00606d34ac1af8025f11d9ab841493966"]; // 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 cf5d43fc0d4fd13b6d6cddd60f2fdf9947e59645..033ce7f304683950775bdcd1e77dce51eb836fec 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 13faecf790838d0a96980f70b269c7a39efe0c11..11f4ab4b4ea7b2ffa3f9d5eac3c2be74924dcb90 100644 --- a/display-app/_expo/static/js/web/bundle.js +++ b/display-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,1490]); +__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,1492]); __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,1486,1489]); +__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,1488,1491]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1225,1226,1231,1235,1237,1244,1298,1299,1300,1301,1302,1303,1305,1306,1307,1308,1312,1315,1316,1317,1318,1321,1395,1396,1397,1399,1441,1442,1485]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1226,1227,1232,1236,1238,1245,1299,1300,1301,1302,1303,1304,1306,1307,1308,1309,1313,1316,1317,1318,1319,1322,1397,1398,1399,1401,1443,1444,1487]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1175,1178,1181,1192,1195,1200,1202,1203,1028,884,920,1205,1156,1206,1207,1208,1217,1210,1154,1219,1223,1196,858,1152,899,1224,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1176,1179,1182,1193,1196,1201,1203,1204,1028,884,920,1206,1157,1207,1208,1209,1218,1211,1155,1220,1224,1197,858,1153,899,1225,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,355 +1222,357 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1156,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,840,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1174,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1175,[812,1176,17,385,85,409,777,876,851,863,804,1177,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1177,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1178,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1179,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1179,[17,777,858,1180,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1180,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1181,[812,1033,1176,17,1182,219,385,409,85,1184,1185,1186,777,816,876,851,1034,804,889,1192,1177,1057,1035,1187,856,1188,1193,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1182,[17,385,85,1183,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1183,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1184,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1185,[17,85,777,812,876,851,1184,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1186,[812,1184,17,385,85,777,884,876,1071,863,804,1177,1057,1187,856,1188,1185,1189,1191,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1187,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1188,[17,85,777,876,1008,1033,1064,1062,1187,804,856,1186,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1189,[1034,1190]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1190,[1034,1184]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1191,[17,85,777,812,1033,1034,1189,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1192,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1177,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1193,[1033,17,385,85,777,812,876,1190,1034,1194,1097,804,1181,1057,1051,1184,1189,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1194,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1195,[813,876,1196,1070,1176,923,924,17,975,976,219,385,278,85,777,858,1071,1197,1186,1162,1198,1059,805,1199,1140,851,863,804,1177,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1189,1191,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1196,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1197,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1198,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1199,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1200,[17,85,777,876,804,1057,1060,1198,1071,1201,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1201,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1202,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1203,[17,219,85,1057,876,1204,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1204,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1205,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1206,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1207,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1208,[843,1028,17,219,385,85,780,858,804,777,1209,1104,1210,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1209,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1210,[1211,1212,1214,1213,1215,1018,1216]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1211,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1212,[824,805,831,834,856,1018,1213]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1213,[843,219,856,1211]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1214,[17,858,845,853,851,1212,1211]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1215,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1216,[17,1212,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1217,[17,385,85,409,858,845,804,777,1208,1104,1218,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1218,[17,85,409,858,845,1210,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1219,[17,219,385,85,864,777,804,916,1220,1221,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1220,[856,806,928,971,916,1210,1221]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1221,[824,1222,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1222,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1223,[17,856,1220]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1224,[17,385,329,85,409,804,1183,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1225,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1226,[843,1099,861,13,17,1227,917,85,841,1228,1079,1055,777,845,851,1105,863,858,899,804,1180,848,995,998,1076,1107,1229,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1227,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1228,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1229,[17,385,85,862,863,1033,1230,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1230,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1231,[900,13,17,319,85,1232,1234,777,845,851,858,867,804,8]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1232,[901,17,1233,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1233,[880,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1234,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1235,[13,17,777,1236,858,1219,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1236,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1237,[822,13,17,1238,777,851,858,804,1239,1243,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1238,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1239,[17,85,777,851,1240,1241,1242,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1240,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1241,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1242,[928,899,1241]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1243,[831,928,971,899,880,1240]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1244,[1245,1246,805,1247,1256,1257,1258,843,13,17,219,385,85,1232,1234,777,845,851,862,858,900,804,1259,1219,856,876,1260,910,911,920,1262,1243,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1245,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1246,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1247,[17,85,777,1248,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1248,[806,1033,1249,1251,1253,17,85,812,777,804,1250,1254,1255,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1250,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1251,[1252,1250]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1252,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1253,[1250]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1254,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1255,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1256,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1157,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,840,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1175,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1176,[812,1177,17,385,85,409,777,876,851,863,804,1178,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1178,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1179,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1180,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1180,[17,777,858,1181,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1181,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1182,[812,1033,1177,17,1183,219,385,409,85,1185,1186,1187,777,816,876,851,1034,804,889,1193,1178,1057,1035,1188,856,1189,1194,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1183,[17,385,85,1184,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1184,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1185,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1186,[17,85,777,812,876,851,1185,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1187,[812,1185,17,385,85,777,884,876,1071,863,804,1178,1057,1188,856,1189,1186,1190,1192,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1188,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1189,[17,85,777,876,1008,1033,1064,1062,1188,804,856,1187,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1190,[1034,1191]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1191,[1034,1185]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1192,[17,85,777,812,1033,1034,1190,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1193,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1178,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1194,[1033,17,385,85,777,812,876,1191,1034,1195,1097,804,1182,1057,1051,1185,1190,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1195,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1196,[813,876,1197,1070,1177,923,924,17,975,976,219,385,278,85,777,858,1071,1198,1187,1163,1199,1059,805,1200,1140,851,863,804,1178,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1190,1192,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1197,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1198,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1199,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1200,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1201,[17,85,777,876,804,1057,1060,1199,1071,1202,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1202,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1203,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1204,[17,219,85,1057,876,1205,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1205,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1206,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1207,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1208,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1209,[843,1028,17,219,385,85,780,858,804,777,1210,1104,1211,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1210,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1211,[1212,1213,1215,1214,1216,1018,1217]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1212,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1213,[824,805,831,834,856,1018,1214]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1214,[843,219,856,1212]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1215,[17,858,845,853,851,1213,1212]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1216,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1217,[17,1213,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1218,[17,385,85,409,858,845,804,777,1209,1104,1219,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1219,[17,85,409,858,845,1211,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1220,[17,219,385,85,864,777,804,916,1221,1222,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1221,[856,806,928,971,916,1211,1222]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1222,[824,1223,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1223,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1224,[17,856,1221]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1225,[17,385,329,85,409,804,1184,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1226,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1227,[843,1099,861,13,17,1228,917,85,841,1229,1079,1055,777,845,851,1105,863,858,899,804,1181,848,995,998,1076,1107,1230,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1228,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1229,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1230,[17,385,85,862,863,1033,1231,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1231,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1232,[900,13,17,319,85,1233,1235,777,845,851,858,867,804,8]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1233,[901,17,1234,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1234,[880,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1235,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1236,[13,17,777,1237,858,1220,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1237,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1238,[822,13,17,1239,777,851,858,804,1240,1244,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1239,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1240,[17,85,777,851,1241,1242,1243,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1241,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1242,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1243,[928,899,1242]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1244,[831,928,971,899,880,1241]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1245,[1246,1247,805,1248,1257,1258,1259,843,13,17,219,385,85,1233,1235,777,845,851,862,858,900,804,1260,1220,856,876,1261,910,911,920,1263,1244,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1246,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1247,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1248,[17,85,777,1249,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1249,[806,1033,1250,1252,1254,17,85,812,777,804,1251,1255,1256,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1251,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1252,[1253,1251]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1253,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1254,[1251]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1255,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1256,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1257,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1258,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1259,[17,385,85,409,777,804,1183,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1260,[813,17,319,378,385,278,85,1232,777,910,845,911,863,804,1019,8,1261]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1261,[]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1262,[17,85,1263,777,858,920,1240,1243,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1263,[17,85,1264,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1264,[1265]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1265,[17,780,1266,1295,1296,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1266,[1267]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1267,[1268,1269,1292,1294]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1268,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1269,[1270,1271,1272,1273,1274,1275,1276,1277,1278,1281,1285,1282,1286]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1270,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1271,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1272,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1273,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1278,[1279]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1282,[1283,1284]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1283,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1284,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1287,[1282]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1288,[1282]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1290,[1282,1270]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1291,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1292,[1293]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1294,[1293]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1295,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1296,[17,780,1297,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1297,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1298,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1299,[822,13,17,85,1263,777,851,858,804,1262,1243,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1300,[822,13,17,85,1238,777,858,876,851,863,804,1239,1243,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1301,[822,13,17,777,858,876,863,804,1262,1243,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1302,[822,13,17,777,858,876,804,1262,1243,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1303,[13,17,777,863,1140,1304,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1304,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1305,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1306,[843,13,17,1227,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1307,[13,17,85,1234,777,845,862,858,804,1259,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1308,[13,17,1309,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1309,[17,85,777,1099,804,1310,1311,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1310,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1311,[928,971,1310]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1312,[843,13,17,85,1236,777,845,851,863,858,804,1313,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1313,[17,354,362,219,13,777,851,804,900,1314,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1314,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1315,[843,1243,13,17,85,777,845,851,863,858,864,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]})}},1316,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1317,[822,13,17,777,858,805,1243,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1318,[13,17,777,1319,1153,1243,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1319,[812,843,17,85,777,845,851,1153,1320,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1320,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1321,[13,17,856,1322,1393,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1322,[1053,779,805,806,1323,813,1324,1094,843,1140,1325,1326,1327,1091,1122,1328,1329,1334,1335,1203,1336,856,1341,1342,1343,1115,1113,920,1344,1152,891,1104,1345,17,1072,1178,1018,1087,1346,378,363,385,278,85,409,19,777,1219,1223,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1347,1108,1348,1354,1356,1359,1364,1358,1365,1368,1369,1117,1095,1096,862,1374,1208,1375,1218,1210,995,1380,1385,1386,1054,1052,1119,1388,1389,1390,1071,1171,1391,1170,1161,853,1337,1392,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1325,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1326,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1327,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1328,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1329,[17,378,385,409,85,1263,777,1171,779,998,1330,1331,1333,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1330,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1331,[17,378,385,278,395,85,409,779,777,804,1332,1333,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1332,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1333,[993,856,1332,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1334,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1335,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1336,[1167,17,219,385,85,777,1166,804,876,920,1337,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1337,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1338,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1338,[831,928,899,1339,880,1340]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1339,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1340,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1341,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1343,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1344,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1345,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1346,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1347,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1348,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1349,1351,1350,998,876,1108,1352,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1349,[813,843,17,1350,85,842,804,777,1109,1351,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1350,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1351,[1350,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1352,[17,368,278,85,842,982,1353,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1353,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1354,[17,219,385,85,804,777,1171,1355,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1355,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1356,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1357,804,777,1358,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1357,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1358,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1359,[805,813,17,266,319,219,385,85,409,804,857,1360,777,999,916,1334,1362,880,1363,1364,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1360,[17,219,85,1361,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1361,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1362,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1364,[17,831,928,899,1363]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1365,[843,841,998,1366,1367]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1366,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1367,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1368,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1369,[1370,843,1095,998,17,85,777,1098,858,1116,1365,1096,863,1093,1117,1118,1119,804,1326,1372,1373,1115,1343,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1370,[17,362,385,85,858,920,876,996,1371,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1371,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1374,[1171,1370,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1358,858,998,845,1089,1076,1304,804,1326,1372,1373,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1375,[812,17,219,385,85,777,858,998,1376,804,1377,1379,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1376,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1377,[831,858,998,1376,1378,1379]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1378,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1379,[219,1378]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1380,[843,17,1182,1171,385,85,995,998,862,863,804,777,1381,1384,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1381,[1382,854,843,17,264,378,385,278,85,858,995,998,1383,863,804,1026,777,1384,1338,899,1326,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1382,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1383,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1384,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1386,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1387,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1388,[843,1366]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1389,[17,385,85,777,1388,804,1346,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1390,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1391,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1392,[17,1005,876,926,816,1006,916,1338,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1393,[805,813,857,17,219,385,85,409,899,804,777,1334,1394,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1394,[]); -__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]})}},1395,[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]})}},1396,[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,{})}},1397,[13,17,1398,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1398,[]); -__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]})}},1399,[13,17,856,1400,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)','')}})}},1400,[1401,1405,813,912,1072,1406,1202,1203,1028,1025,1026,1407,1409,1412,1152,891,978,1414,975,880,1031,1032,1415,914,1008,915,17,1154,1219,1223,1196,356,385,278,85,409,19,777,857,876,804,1160,1416,1066,1084,1086,1081,1027,1010,1057,1423,1424,1425,1434,1435,920,219,1224,1175,1181,1431,1195,1192,1440,1178,878,1205,1206,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1401,[812,17,1018,378,85,1108,1109,1348,1380,777,995,998,863,804,1057,999,1402,1403,1020,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WipeDevice=function(n){return null}},1402,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1403,[17,85,777,998,1404,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1404,[]); -__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']]},1405,[17,85,777,1057,899,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)},1406,[843,17,85,777,845,851,1153,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)}}})]})}},1407,[899,17,264,219,85,1263,777,1240,1243,804,1408,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},1408,[17,219,85,777,1240,8]); -__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}},1409,[17,779,85,777,845,1240,1410,1411,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'},1410,[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()})},1411,[899,1410,1243]); -__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'})})}},1412,[805,1413,17,85,777,851,1240,1241,1242,899,1243,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1413,[]); -__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}},1414,[219,976]); -__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]},1415,[17,85,777,804,914,1022,899,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1416,[805,1413,1095,1250,1417,812,822,1117,1118,1091,1122,1418,1114,1119,1388,1389,1057,1326,996,1120,1089,841,1367,1125,1420,1219,1421,1380,1078,1055,1090,17,85,777,1346,858,845,851,863,1304,804,1177,1098,1115,998,1343,1062,1161,1422,1210,899,1179,1385,862,8]); -__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])},1417,[806,17,85,777,899,1254,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1418,[17,385,85,1419,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1419,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1420,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1180,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1421,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1422,[17,85,864,858,848,804,777,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])},1423,[17,1381,1057,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])},1424,[843,17,85,1161,777,858,845,853,863,804,1177,1057,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})},1425,[820,896,1426,17,219,85,777,816,876,895,1000,897,899,1433,804,880,1162,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1426,[812,891,1140,899,780,1208,1210,17,264,362,219,385,85,409,864,777,858,1219,876,851,863,804,1177,1057,853,1055,1427,1160,1431,1432,1139,1145,1144,1008,839,1142,1148,1430,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1427,[886,779,816,813,822,862,1039,1428,17,909,319,362,219,385,85,777,858,876,863,804,1177,1057,1430,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1428,[482,1429]); -__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}});var t={}},1429,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1430,[816,876,805]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1431,[812,17,1233,1026,854,362,385,85,777,876,851,863,804,1177,1057,1430,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1432,[978,17,385,85,777,876,804,1057,1160,899,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'}},1433,[]); -__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)','')},1434,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1435,[1436,17,219,24,85,856,1437,920,804,1439,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1436,[]); -__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])},1437,[17,278,85,777,857,804,1438,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(' ')},1438,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1439,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1440,[1178,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1175,1427,1161,860,1179,853,1177,884,1343,998,843,1115,1192,1199,1071,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]})}},1441,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1442,[1443,899,778,1394,1445,995,13,1472,479,17,368,319,219,24,85,805,857,1065,856,1474,19,858,998,876,804,1435,920,988,1477,1478,1028,1104,880,1008,914,1480,1364,8,1481,1482,1483,1484]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1443,[880,812,17,219,366,85,777,1444,899,804,1181,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1444,[]); -__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])},1445,[1446,1469,1471]); -__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)}}},1446,[198,1447,1450,1464,1465,1466,1467,1468]); -__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}},1447,[198,1448]); -__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}},1448,[1449]); -__d(function(g,r,i,a,m,e,d){},1449,[]); -__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)}},1450,[1451,198,1447,1464,1465]); -__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]}})})},1451,[1452,1453,1463]); -__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()}})}},1452,[1453,1457,1462]); -__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}}},1453,[198,355,1454,1458,1459,1460,1461,1457,1462]); -__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}},1454,[198,1455,322,263,1456,1457]); -__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])},1455,[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}}},1456,[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},1457,[]); -__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}},1458,[]); -__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}},1459,[]); -__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])},1460,[1458]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},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,"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},1462,[355,1456]); -__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])},1463,[17,1453]); -__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}},1464,[1451,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])},1465,[1451,1464]); -__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}},1466,[1447]); -__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])},1467,[198,1447,1450,1448]); -__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})({})},1468,[]); -__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]))},1469,[198,37,1470]); -__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')},1470,[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]}},1471,[17,1446]); -__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]}})})},1472,[1473]); -__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(){}},1473,[]); -__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]})}},1474,[17,24,85,409,777,857,920,899,880,805,804,1475,1476,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1475,[]); -__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])},1476,[17,85,777,804,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()})},1477,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1478,[813,779,17,974,385,85,856,899,976,804,777,1334,971,880,1479,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SyncDeviceActions=function(){return null}},1479,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1480,[]); -__d(function(e,s,o,p,t,a,n){"use strict";t.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1481,[]); -__d(function(s,o,p,e,d,t,c){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1482,[]); -__d(function(o,s,p,e,d,t,f){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1483,[]); -__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1484,[]); -__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]})}},1485,[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},1486,[1487]); -__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},1487,[8,1488,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}))}}},1488,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1489,[]); -__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})}}},1490,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1259,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1260,[17,385,85,409,777,804,1184,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1261,[813,17,319,378,385,278,85,1233,777,910,845,911,863,804,1019,8,1262]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1262,[]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1263,[17,85,1264,777,858,920,1241,1244,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1264,[17,85,1265,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1265,[1266]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1266,[17,780,1267,1296,1297,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1267,[1268]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1268,[1269,1270,1293,1295]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1269,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1270,[1271,1272,1273,1274,1275,1276,1277,1278,1279,1282,1286,1283,1287]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1271,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1272,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1273,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1274,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1279,[1280]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1283,[1284,1285]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1284,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1285,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1288,[1283]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1289,[1283]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1291,[1283,1271]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1292,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1293,[1294]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1295,[1294]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1296,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1297,[17,780,1298,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1298,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1299,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1300,[822,13,17,85,1264,777,851,858,804,1263,1244,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1301,[822,13,17,85,1239,777,858,876,851,863,804,1240,1244,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1302,[822,13,17,777,858,876,863,804,1263,1244,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1303,[822,13,17,777,858,876,804,1263,1244,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1304,[13,17,777,863,1140,1305,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1305,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1306,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1307,[843,13,17,1228,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1308,[13,17,85,1235,777,845,862,858,804,1260,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1309,[13,17,1310,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1310,[17,85,777,1099,804,1311,1312,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1311,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1312,[928,971,1311]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1313,[843,13,17,85,1237,777,845,851,863,858,804,1314,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1314,[17,354,362,219,13,777,851,804,900,1315,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1315,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1316,[843,1244,13,17,85,777,845,851,863,858,864,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]})}},1317,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1318,[822,13,17,777,858,805,1244,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1319,[13,17,777,1320,1154,1244,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1320,[812,843,17,85,777,845,851,1154,1321,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1321,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1322,[13,17,856,1323,1395,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1323,[1053,779,805,806,1324,813,1325,1094,843,1140,1326,1327,1328,1091,1122,1329,1330,1335,1336,1204,1337,856,1342,1343,1344,1115,1113,920,1345,1153,891,1104,1346,17,1072,1179,1018,1087,1347,21,378,363,385,278,85,409,19,777,1220,1224,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1348,1108,1349,1355,1357,1361,1366,1360,1367,1370,1371,1117,1095,1096,862,1376,1209,1377,1219,1211,995,1382,1387,1388,1054,1052,1119,1390,1391,1392,1071,1172,1393,1171,1162,853,1338,1394,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1326,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1327,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1328,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1329,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1330,[17,378,385,409,85,1264,777,1172,779,998,1331,1332,1334,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1331,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1332,[17,378,385,278,395,85,409,779,777,804,1333,1334,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1333,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1334,[993,856,1333,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1335,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1336,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1337,[1168,17,219,385,85,777,1167,804,876,920,1338,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1338,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1339,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1339,[831,928,899,1340,880,1341]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1340,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1341,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1342,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1344,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1345,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1346,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1347,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1348,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1349,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1350,1352,1351,998,876,1108,1353,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1350,[813,843,17,1351,85,842,804,777,1109,1352,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1351,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1352,[1351,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1353,[17,368,278,85,842,982,1354,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1354,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1355,[17,219,385,85,804,777,1172,1356,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1356,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1357,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1358,841,863,1096,1359,804,777,1360,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1358,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1359,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1360,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1361,[805,813,17,266,319,219,385,85,409,804,857,1362,777,999,916,1335,1364,880,1365,1366,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1362,[17,219,85,1363,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1363,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1364,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1366,[17,831,928,899,1365]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1367,[843,841,998,1368,1369]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1368,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1369,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1370,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1371,[1372,843,1095,998,17,85,777,1098,858,1116,1367,1096,863,1093,1117,1118,1119,804,1327,1374,1375,1115,1344,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1372,[17,362,385,85,858,920,876,996,1373,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1373,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1376,[1172,1372,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1360,858,998,845,1089,1076,1305,804,1327,1374,1375,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1377,[812,17,219,385,85,777,858,998,1378,804,1379,1381,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1378,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1379,[831,858,998,1378,1380,1381]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1380,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1381,[219,1380]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1382,[843,17,1183,1172,385,85,995,998,862,863,804,777,1383,1386,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1383,[1384,854,843,17,264,378,385,278,85,858,995,998,1385,863,804,1026,777,1386,1339,899,1327,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1384,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1385,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1386,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1388,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1389,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1390,[843,1368]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1391,[17,385,85,777,1390,804,1347,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1392,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1393,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1394,[17,1005,876,926,816,1006,916,1339,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1395,[805,813,857,17,219,385,85,409,899,804,777,1335,1396,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1396,[]); +__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]})}},1397,[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]})}},1398,[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,{})}},1399,[13,17,1400,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1400,[]); +__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]})}},1401,[13,17,856,1402,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)','')}})}},1402,[1403,1407,813,912,1072,1408,1203,1204,1028,1025,1026,1409,1411,1414,1153,891,978,1416,975,880,1031,1032,1417,914,1008,915,17,1155,1220,1224,1197,356,385,278,85,409,19,777,857,876,804,1161,1418,1066,1084,1086,1081,1027,1010,1057,1425,1426,1427,1436,1437,920,219,1225,1176,1182,1433,1196,1193,1442,1179,878,1206,1207,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1403,[812,17,1018,378,85,1108,1109,1349,1382,777,995,998,863,804,1057,999,1404,1405,1020,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WipeDevice=function(n){return null}},1404,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1405,[17,85,777,998,1406,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1406,[]); +__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']]},1407,[17,85,777,1057,899,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)},1408,[843,17,85,777,845,851,1154,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)}}})]})}},1409,[899,17,264,219,85,1264,777,1241,1244,804,1410,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},1410,[17,219,85,777,1241,8]); +__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}},1411,[17,779,85,777,845,1241,1412,1413,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'},1412,[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()})},1413,[899,1412,1244]); +__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'})})}},1414,[805,1415,17,85,777,851,1241,1242,1243,899,1244,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1415,[]); +__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}},1416,[219,976]); +__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]},1417,[17,85,777,804,914,1022,899,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1418,[805,1415,1095,1251,1419,812,822,1117,1118,1091,1122,1420,1114,1119,1390,1391,1057,1327,996,1120,1089,841,1369,1125,1422,1220,1423,1382,1078,1055,1090,17,85,777,1347,858,845,851,863,1305,804,1178,1098,1115,998,1344,1062,1162,1424,1211,899,1180,1387,862,8]); +__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])},1419,[806,17,85,777,899,1255,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[17,385,85,1421,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1181,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1424,[17,85,864,858,848,804,777,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])},1425,[17,1383,1057,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])},1426,[843,17,85,1162,777,858,845,853,863,804,1178,1057,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})},1427,[820,896,1428,17,219,85,777,816,876,895,1000,897,899,1435,804,880,1163,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1428,[812,891,1140,899,780,1209,1211,17,264,362,219,385,85,409,864,777,858,1220,876,851,863,804,1178,1057,853,1055,1429,1161,1433,1434,1139,1146,1145,1008,839,1142,1149,1432,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1429,[886,779,816,813,822,862,1039,1430,17,909,319,362,219,385,85,777,858,876,863,804,1178,1057,1432,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1430,[482,1431]); +__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}});var t={}},1431,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1432,[816,876,805]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1433,[812,17,1234,1026,854,362,385,85,777,876,851,863,804,1178,1057,1432,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1434,[978,17,385,85,777,876,804,1057,1161,899,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'}},1435,[]); +__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)','')},1436,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1437,[1438,17,219,24,85,856,1439,920,804,1441,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1438,[]); +__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])},1439,[17,278,85,777,857,804,1440,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(' ')},1440,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1441,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1442,[1179,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1176,1429,1162,860,1180,853,1178,884,1344,998,843,1115,1193,1200,1071,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]})}},1443,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1444,[1445,899,778,1396,1447,995,13,1474,479,17,368,319,219,24,85,805,857,1065,856,1476,19,858,998,876,804,1437,920,988,1479,1480,1028,1104,880,1008,914,1482,1366,8,1483,1484,1485,1486]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1445,[880,812,17,219,366,85,777,1446,899,804,1182,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1446,[]); +__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])},1447,[1448,1471,1473]); +__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)}}},1448,[198,1449,1452,1466,1467,1468,1469,1470]); +__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}},1449,[198,1450]); +__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}},1450,[1451]); +__d(function(g,r,i,a,m,e,d){},1451,[]); +__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)}},1452,[1453,198,1449,1466,1467]); +__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]}})})},1453,[1454,1455,1465]); +__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()}})}},1454,[1455,1459,1464]); +__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}}},1455,[198,355,1456,1460,1461,1462,1463,1459,1464]); +__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}},1456,[198,1457,322,263,1458,1459]); +__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])},1457,[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}}},1458,[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},1459,[]); +__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}},1460,[]); +__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}},1461,[]); +__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])},1462,[1460]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1463,[]); +__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},1464,[355,1458]); +__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])},1465,[17,1455]); +__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}},1466,[1453,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])},1467,[1453,1466]); +__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}},1468,[1449]); +__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])},1469,[198,1449,1452,1450]); +__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})({})},1470,[]); +__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]))},1471,[198,37,1472]); +__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')},1472,[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]}},1473,[17,1448]); +__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]}})})},1474,[1475]); +__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(){}},1475,[]); +__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]})}},1476,[17,24,85,409,777,857,920,899,880,805,804,1477,1478,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1477,[]); +__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])},1478,[17,85,777,804,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()})},1479,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1480,[813,779,17,974,385,85,856,899,976,804,777,1335,971,880,1481,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SyncDeviceActions=function(){return null}},1481,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1482,[]); +__d(function(e,s,o,p,t,a,n){"use strict";t.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1483,[]); +__d(function(s,o,p,e,d,t,c){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1484,[]); +__d(function(o,s,p,e,d,t,f){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1485,[]); +__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1486,[]); +__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]})}},1487,[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},1488,[1489]); +__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},1489,[8,1490,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}))}}},1490,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1491,[]); +__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})}}},1492,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/display-app/admin.html b/display-app/admin.html index 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 d3ef5486af33aacdf57401d94c86fcfb7e800d28..fd078e6eaf3ad74499d595e5935cff935ac80e24 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 e97ab9db42783b879e72e223e02d450a80fc4bc0..4a6dda8712c5e6befecaddcd14ec1f1f605eab55 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-fff260218e"; +const V = "cc-display-a55bdf4e02"; 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=fff260218e577ca55e1c9473a2751a9af5cad846ad67a3f570552afc7e74a7a8"]; +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=a55bdf4e02256cfc2150d3337318972c6dacf80460574ab6147d8d92ac6d26d3"]; // 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 66a5646c66245f4a7b75cf5d40fe32cd9700b753..6b4c0845b94b53b627cf354bc255ffb19fcf87bd 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 fbd66af84fba4668ae0e410522dd3a7ed8ad37ba..7278687b820e21e73dde32a890774937f588d4f0 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ -Cover Charge: try the apps (v0.3.12.208) +Cover Charge: try the apps (v0.3.12.209) @@ -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.208)

+

Cover Charge: try the apps (v0.3.12.209)

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.208

+

Cover Charge v0.3.12.209

diff --git a/owner-app/_expo/static/js/web/bundle.js b/owner-app/_expo/static/js/web/bundle.js index 841dc2684ca1f0e9517e15e082d48539897aecdb..7d275b1d7211e698ce892e7283d2e9eaf55b501d 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,1631]); +__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,1633]); __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,1627,1630]); +__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,1629,1632]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1246,1247,1252,1254,1256,1263,1315,1316,1317,1318,1319,1320,1322,1323,1324,1325,1329,1332,1333,1334,1335,1338,1412,1413,1414,1581,1586,1587,1626]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1247,1248,1253,1255,1257,1264,1316,1317,1318,1319,1320,1321,1323,1324,1325,1326,1330,1333,1334,1335,1336,1339,1414,1415,1416,1583,1588,1589,1628]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1181,1184,1187,1198,1201,1206,1208,1209,1028,884,920,1211,1156,1212,1224,1229,1238,1231,1154,1240,1244,1202,858,1152,899,1245,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1182,1185,1188,1199,1202,1207,1209,1210,1028,884,920,1212,1157,1213,1225,1230,1239,1232,1155,1241,1245,1203,858,1153,899,1246,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,496 +1222,498 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1156,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1174,[812,17,385,85,777,779,905,858,847,906,907,804,889,1175,1179,1156,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1176,[1177,928,899,856,880,1178,1038]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1177,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1178,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1179,[17,85,780,777,905,858,908,804,889,1156,1180,8]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1180,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1181,[812,1182,17,385,85,409,777,876,851,863,804,1183,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1183,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1184,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1185,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1185,[17,777,858,1186,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1186,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1187,[812,1033,1182,17,1188,219,385,409,85,1190,1191,1192,777,816,876,851,1034,804,889,1198,1183,1057,1035,1193,856,1194,1199,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1188,[17,385,85,1189,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1189,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1190,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1191,[17,85,777,812,876,851,1190,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1192,[812,1190,17,385,85,777,884,876,1071,863,804,1183,1057,1193,856,1194,1191,1195,1197,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1193,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1194,[17,85,777,876,1008,1033,1064,1062,1193,804,856,1192,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1195,[1034,1196]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1196,[1034,1190]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1197,[17,85,777,812,1033,1034,1195,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1198,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1183,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1199,[1033,17,385,85,777,812,876,1196,1034,1200,1097,804,1187,1057,1051,1190,1195,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1200,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1201,[813,876,1202,1070,1182,923,924,17,975,976,219,385,278,85,777,858,1071,1203,1192,1162,1204,1059,805,1205,1140,851,863,804,1183,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1195,1197,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1202,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1203,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1204,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1205,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1206,[17,85,777,876,804,1057,1060,1204,1071,1207,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1207,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1208,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1209,[17,219,85,1057,876,1210,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1210,[]); -__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1211,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1212,[812,1213,779,1214,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1215,1218,1221,1223,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1213,[880,805,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1214,[17,1003,876,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1215,[219,1216]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1216,[1217,856]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1217,[928,903]); -__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1218,[813,1213,1033,779,812,1214,820,876,17,319,385,85,780,777,884,1003,1004,1219,804,889,1215,1220,8]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1219,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1220,[816,876,805]); -__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1221,[17,1033,362,219,85,777,876,1003,1220,1004,1222,804,889,1214,928,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1222,[1004,991]); -__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1223,[17,85,777,804,889,992,905,858,876,1033,1222,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1224,[17,1157,1158,385,85,777,910,845,911,804,889,1225,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1225,[813,17,319,378,385,278,85,1226,777,910,845,911,863,804,1019,8,1228]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1226,[901,17,1227,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1227,[880,899]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1228,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1229,[843,1028,17,219,385,85,780,858,804,777,1230,1104,1231,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1230,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1231,[1232,1233,1235,1234,1236,1018,1237]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1232,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1233,[824,805,831,834,856,1018,1234]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1234,[843,219,856,1232]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1235,[17,858,845,853,851,1233,1232]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1236,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1237,[17,1233,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1238,[17,385,85,409,858,845,804,777,1229,1104,1239,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1239,[17,85,409,858,845,1231,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1240,[17,219,385,85,864,777,804,916,1241,1242,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1241,[856,806,928,971,916,1231,1242]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1242,[824,1243,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1243,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1244,[17,856,1241]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1245,[17,385,329,85,409,804,1189,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1246,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1247,[843,1099,861,13,17,1248,917,85,841,1249,1079,1055,777,845,851,1105,863,858,899,804,1186,848,995,998,1076,1107,1250,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1248,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1249,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1250,[17,385,85,862,863,1033,1251,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1251,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1252,[900,13,17,319,85,1226,1253,777,845,851,858,867,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1253,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1254,[13,17,777,1255,858,1240,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1255,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1256,[822,13,17,1257,777,851,858,804,1258,1262,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1257,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1258,[17,85,777,851,1259,1260,1261,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1259,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1260,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1261,[928,899,1260]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1262,[831,928,971,899,880,1259]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1263,[1264,1265,805,1266,1275,1276,1277,843,13,17,219,385,85,1226,1253,777,845,851,862,858,900,804,1278,1240,856,876,1225,910,911,920,1279,1262,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1264,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1265,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1266,[17,85,777,1267,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1267,[806,1033,1268,1270,1272,17,85,812,777,804,1269,1273,1274,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1269,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1270,[1271,1269]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1271,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1272,[1269]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1273,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1274,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1275,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1157,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1175,[812,17,385,85,777,779,905,858,847,906,907,804,889,1176,1180,1157,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1177,[1178,928,899,856,880,1179,1038]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1178,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1179,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1180,[17,85,780,777,905,858,908,804,889,1157,1181,8]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1181,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1182,[812,1183,17,385,85,409,777,876,851,863,804,1184,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1184,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1185,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1186,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1186,[17,777,858,1187,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1187,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1188,[812,1033,1183,17,1189,219,385,409,85,1191,1192,1193,777,816,876,851,1034,804,889,1199,1184,1057,1035,1194,856,1195,1200,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1189,[17,385,85,1190,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1190,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1191,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1192,[17,85,777,812,876,851,1191,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1193,[812,1191,17,385,85,777,884,876,1071,863,804,1184,1057,1194,856,1195,1192,1196,1198,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1194,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1195,[17,85,777,876,1008,1033,1064,1062,1194,804,856,1193,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1196,[1034,1197]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1197,[1034,1191]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1198,[17,85,777,812,1033,1034,1196,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1199,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1184,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1200,[1033,17,385,85,777,812,876,1197,1034,1201,1097,804,1188,1057,1051,1191,1196,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1201,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1202,[813,876,1203,1070,1183,923,924,17,975,976,219,385,278,85,777,858,1071,1204,1193,1163,1205,1059,805,1206,1140,851,863,804,1184,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1196,1198,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1203,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1204,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1205,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1206,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1207,[17,85,777,876,804,1057,1060,1205,1071,1208,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1208,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1209,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1210,[17,219,85,1057,876,1211,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1211,[]); +__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1212,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1213,[812,1214,779,1215,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1216,1219,1222,1224,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1214,[880,805,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1215,[17,1003,876,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1216,[219,1217]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1217,[1218,856]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1218,[928,903]); +__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1219,[813,1214,1033,779,812,1215,820,876,17,319,385,85,780,777,884,1003,1004,1220,804,889,1216,1221,8]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1220,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1221,[816,876,805]); +__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1222,[17,1033,362,219,85,777,876,1003,1221,1004,1223,804,889,1215,928,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1223,[1004,991]); +__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1224,[17,85,777,804,889,992,905,858,876,1033,1223,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1225,[17,1158,1159,385,85,777,910,845,911,804,889,1226,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1226,[813,17,319,378,385,278,85,1227,777,910,845,911,863,804,1019,8,1229]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1227,[901,17,1228,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1228,[880,899]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1229,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1230,[843,1028,17,219,385,85,780,858,804,777,1231,1104,1232,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1231,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1232,[1233,1234,1236,1235,1237,1018,1238]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1233,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1234,[824,805,831,834,856,1018,1235]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1235,[843,219,856,1233]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1236,[17,858,845,853,851,1234,1233]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1237,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1238,[17,1234,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1239,[17,385,85,409,858,845,804,777,1230,1104,1240,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1240,[17,85,409,858,845,1232,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1241,[17,219,385,85,864,777,804,916,1242,1243,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1242,[856,806,928,971,916,1232,1243]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1243,[824,1244,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1244,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1245,[17,856,1242]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1246,[17,385,329,85,409,804,1190,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1247,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1248,[843,1099,861,13,17,1249,917,85,841,1250,1079,1055,777,845,851,1105,863,858,899,804,1187,848,995,998,1076,1107,1251,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1249,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1250,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1251,[17,385,85,862,863,1033,1252,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1252,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1253,[900,13,17,319,85,1227,1254,777,845,851,858,867,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1254,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1255,[13,17,777,1256,858,1241,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1256,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1257,[822,13,17,1258,777,851,858,804,1259,1263,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1258,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1259,[17,85,777,851,1260,1261,1262,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1260,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1261,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1262,[928,899,1261]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1263,[831,928,971,899,880,1260]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1264,[1265,1266,805,1267,1276,1277,1278,843,13,17,219,385,85,1227,1254,777,845,851,862,858,900,804,1279,1241,856,876,1226,910,911,920,1280,1263,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1265,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1266,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1267,[17,85,777,1268,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1268,[806,1033,1269,1271,1273,17,85,812,777,804,1270,1274,1275,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1270,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1271,[1272,1270]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1272,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1273,[1270]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1274,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1275,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1276,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1277,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1278,[17,385,85,409,777,804,1189,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1279,[17,85,1280,777,858,920,1259,1262,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1280,[17,85,1281,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1281,[1282]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1282,[17,780,1283,1312,1313,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1283,[1284]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1284,[1285,1286,1309,1311]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1285,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1286,[1287,1288,1289,1290,1291,1292,1293,1294,1295,1298,1302,1299,1303]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1287,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1288,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1289,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1290,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1295,[1296]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1299,[1300,1301]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1300,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1301,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1304,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1305,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1307,[1299,1287]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1308,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1309,[1310]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1311,[1310]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1312,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1313,[17,780,1314,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1314,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1315,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1316,[822,13,17,85,1280,777,851,858,804,1279,1262,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1317,[822,13,17,85,1257,777,858,876,851,863,804,1258,1262,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1318,[822,13,17,777,858,876,863,804,1279,1262,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1319,[822,13,17,777,858,876,804,1279,1262,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1320,[13,17,777,863,1140,1321,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1321,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1322,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1323,[843,13,17,1248,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1324,[13,17,85,1253,777,845,862,858,804,1278,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1325,[13,17,1326,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1326,[17,85,777,1099,804,1327,1328,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1327,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1328,[928,971,1327]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1329,[843,13,17,85,1255,777,845,851,863,858,804,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1330,[17,354,362,219,13,777,851,804,900,1331,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1331,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1332,[843,1262,13,17,85,777,845,851,863,858,864,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]})}},1333,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1334,[822,13,17,777,858,805,1262,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1335,[13,17,777,1336,1153,1262,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1336,[812,843,17,85,777,845,851,1153,1337,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1337,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1338,[13,17,856,1339,1410,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1339,[1053,779,805,806,1340,813,1341,1094,843,1140,1342,1343,1344,1091,1122,1345,1346,1351,1352,1209,1353,856,1358,1359,1360,1115,1113,920,1361,1152,891,1104,1362,17,1072,1184,1018,1087,1363,378,363,385,278,85,409,19,777,1240,1244,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1364,1108,1365,1371,1373,1376,1381,1375,1382,1385,1386,1117,1095,1096,862,1391,1229,1392,1239,1231,995,1397,1402,1403,1054,1052,1119,1405,1406,1407,1071,1171,1408,1170,1161,853,1354,1409,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1342,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1343,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1344,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1345,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1346,[17,378,385,409,85,1280,777,1171,779,998,1347,1348,1350,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1347,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1348,[17,378,385,278,395,85,409,779,777,804,1349,1350,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1349,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1350,[993,856,1349,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1351,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1352,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1353,[1167,17,219,385,85,777,1166,804,876,920,1354,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1354,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1355,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1355,[831,928,899,1356,880,1357]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1356,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1357,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1358,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1360,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1361,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1362,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1363,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1364,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1365,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1366,1368,1367,998,876,1108,1369,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1366,[813,843,17,1367,85,842,804,777,1109,1368,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1367,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1368,[1367,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1369,[17,368,278,85,842,982,1370,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[17,219,385,85,804,777,1171,1372,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1374,804,777,1375,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1376,[805,813,17,266,319,219,385,85,409,804,857,1377,777,999,916,1351,1379,880,1380,1381,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1377,[17,219,85,1378,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1378,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1379,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1381,[17,831,928,899,1380]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1382,[843,841,998,1383,1384]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1383,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1384,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1385,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1386,[1387,843,1095,998,17,85,777,1098,858,1116,1382,1096,863,1093,1117,1118,1119,804,1343,1389,1390,1115,1360,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1387,[17,362,385,85,858,920,876,996,1388,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1388,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1391,[1171,1387,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1375,858,998,845,1089,1076,1321,804,1343,1389,1390,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1392,[812,17,219,385,85,777,858,998,1393,804,1394,1396,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1393,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1394,[831,858,998,1393,1395,1396]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1395,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1396,[219,1395]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1397,[843,17,1188,1171,385,85,995,998,862,863,804,777,1398,1401,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1398,[1399,854,843,17,264,378,385,278,85,858,995,998,1400,863,804,1026,777,1401,1355,899,1343,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1399,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1400,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1401,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1403,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1404,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1405,[843,1383]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1406,[17,385,85,777,1405,804,1363,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1407,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1408,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[17,1005,876,926,816,1006,916,1355,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[805,813,857,17,219,385,85,409,899,804,777,1351,1411,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); -__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]})}},1412,[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]})}},1413,[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,{})}},1414,[13,17,1415,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])},1415,[17,856,1416,1557,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 H.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]),Y=_r(d[45]);_r(d[46]);var 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,Q.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,Q.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,K.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,K.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,J.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)(()=>{G.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,M.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)(z.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)(z.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'!==H.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'===H.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'===H.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.jsx)(D.AssistantRequestsButton,{go:Be,testID:"assistant-requests-top"}),(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'===H.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)(F.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(Y.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(U.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(Q.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(K.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.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)(W.OnboardingHost,{go:Be}),(0,le.jsx)(V.CoachHost,{})]})}},1416,[805,813,899,1192,1227,1209,1028,1025,891,1026,880,1032,1087,17,356,378,385,278,409,85,19,777,857,858,876,804,1417,1183,1057,884,1425,920,219,1430,1470,839,856,1472,1479,1480,1481,1189,1245,1482,1456,1483,1485,1454,1160,1229,1392,1231,1244,1487,1084,1086,1553,1554,1573,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1417,[805,1418,1095,1269,1419,812,822,1117,1118,1091,1122,1420,1114,1119,1405,1406,1057,1343,996,1120,1089,841,1384,1125,1422,1240,1423,1397,1078,1055,1090,17,85,777,1363,858,845,851,863,1321,804,1183,1098,1115,998,1360,1062,1161,1424,1231,899,1185,1402,862,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1418,[]); -__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])},1419,[806,17,85,777,899,1273,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[17,385,85,1421,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1186,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1424,[17,85,864,858,848,804,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1425,[1426,17,219,24,85,856,1427,920,804,1429,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1426,[]); -__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])},1427,[17,278,85,777,857,804,1428,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(' ')},1428,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1429,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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:n=!1}){const{rid:a,r:x,now:H,role:ae,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(a),ce=(0,p.useBookings)(a),ue=(0,p.useWaitlist)(a),ge=(0,p.useEvents)(a),xe=(0,p.useRatings)(a),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,S.useRealHistory)(a,H),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,H,pe??void 0),[x,ce,de,ge,pe,H.getTime()/6e4|0]),ke=(0,M.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),Ie=de.filter(B.LIVE),ve=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=Ie.filter(e=>(0,U.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,U.bookingNeedsAction)(e,Ie)),Ae=Ie.flatMap(e=>(0,I.readinessFor)(e,x,H).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Se=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Me=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,v.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(H),He=ke?(0,L.revenueHistory)(x,H,7).filter(e=>e.date.getDay()===H.getDay()).pop():void 0,Fe=ke?{today:186e3+Ne,last:He?{date:(0,v.ymd)(He.date),pence:He.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,a,Pe,Ne),We=j.CAN.takings(ae)&&(!(0,W.isLive)()||(0,W.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,H,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(H),(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)(ae,qe,{inStaffApp:Ye,live:(0,W.isLive)()}),Ve=(0,F.homeSetupNagsHidden)(a),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,st]=(0,l.useState)(!1),ot=ie.replace(' (example)',''),lt=j.CAN.manage(ae)?(0,ne.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,ne.jsxs)(b.default,{style:{gap:12},children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(i.DayView,{rid:a,day:Ue,today:re,app:"owner"})]}):(0,ne.jsxs)(b.default,{style:{gap:12},testID:n?'owner-home':'managers-home',children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(K.WhoBar,{}),qe&&'owner'!==qe.role?(0,ne.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ne.jsx)(X.MyTasksToday,{rid:a,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ae?(0,ne.jsx)(Z.TodaysTipsCard,{rid:a,today:re}):null,'staff'!==ae?(0,ne.jsx)(Z.TipsPotCard,{rid:a,today:re}):null,j.CAN.manage(ae)?(0,ne.jsx)(b.default,{testID:"home-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.jsx)(f.Button,{testID:"home-insights-toggle",kind:tt?'secondary':'primary',label:tt?'Hide insights':'Insights',accessibilityLabel:tt?'Hide insights':'Insights: business insights, stats and suggestions. Closed until you tap.',onPress:()=>st(e=>!e),style:{minHeight:56,width:'100%'}})}):null,j.CAN.manage(ae)&&tt?(0,ne.jsxs)(b.default,{testID:"home-insights-panel",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,ne.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.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%'}})}),(0,ne.jsx)(le.SuperProInsights,{go:e}),(0,ne.jsxs)(b.default,{testID:"home-insights-feed",style:{gap:12,width:'100%'},children:[(0,ne.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,ne.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ne.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,ne.jsxs)(f.T,{weight:"semibold",center:!0,children:[t.icon," ",t.title]}),(0,ne.jsx)(f.Muted,{center:!0,children:t.body}),t.action?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'center'}}):null]})},t.id)),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights'),style:{alignSelf:'center'}})]})]}):null,(0,ne.jsx)(ye,{split:De}),(0,ne.jsx)(te.BlocksBanner,{rid:a,now:H,by:ie}),(0,ne.jsx)(y.KitchenSignoffs,{rid:a,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(o.SeasonsTodo,{go:e}):null,(0,ne.jsx)(r.LastFoodBanner,{rid:a,now:H}),(0,ne.jsx)(d.NextTableFreeCard,{rid:a,now:H}),j.CAN.manage(ae)?(0,ne.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,ne.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,ne.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ne.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ae)?(0,ne.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:a,r:x,now:H,by:ie}):null]}),ze.elements,j.CAN.manage(ae)?(0,ne.jsx)(Y.PaydaysCard,{go:e}):null,(0,ne.jsx)(E.FadeIn,{children:(0,ne.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ne.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,ne.jsx)(S.ExampleBadge,{}):je.enough?(0,ne.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ne.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ne.jsx)(E.Gauge,{pct:Le?Se.pct:0,label:Le?Se.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,ne.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ne.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,je.enough?(0,ne.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,ne.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ne.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ne.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||Ie.length?(0,ne.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Live orders",value:"",accent:Ie.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${Ie.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${Ie.filter(e=>'table'===e.type).length} table`:`${Ie.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ne.jsx)(E.CountUp,{value:Ie.length})})}):null,ve.length>0?(0,ne.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ne.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,ne.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(z.TakingsTodayCard,{t:Fe,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ne.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ne.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,ne.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,ne.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ne.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,v.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ne.jsx)(f.T,{size:14,children:t.detail}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ge.days.length||Ge.requests)?(0,ne.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,ne.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ae)?(0,ne.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ne.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ne.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ne.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,ne.jsxs)(f.Row,{gap:4,children:[(0,ne.jsx)(G.Mark,{p:"facebook"}),(0,ne.jsx)(G.Mark,{p:"instagram"}),(0,ne.jsx)(G.Mark,{p:"tiktok"}),(0,ne.jsx)(G.Mark,{p:"youtube"})]}),(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ne.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ne.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ne.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ne.jsx)(B.SectionHead,{title:e})}),(0,ne.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ne.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ne.jsxs)(f.Card,{children:[0===Oe.length?(0,ne.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,ne.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ne.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,v.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ne.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ne.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),Ke?(0,ne.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,ne.jsx)(E.FadeIn,{children:(0,ne.jsx)(he,{rid:a,today:re})}):null,'owner'!==ae||V.IS_CAR?null:(0,ne.jsx)(f.Button,{testID:"home-customer-support",label:"Customer support",accessibilityLabel:"Customer support, send a message or a picture to CoverCharge",onPress:()=>e('more','support'),style:{minHeight:56,width:'100%'}}),(0,ne.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:a,by:ot,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]),n=_r(_d[4]),a=e(n),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]),I=_r(_d[21]),v=_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]),S=_r(_d[29]),M=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),H=_r(_d[33]),F=_r(_d[34]),W=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),_=_r(_d[41]),U=_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]),ne=_r(_d[56]);const ae=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 a=3/Math.sqrt(n);o[e]=a*t*s[e],o[e+1]=a*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)&&n.push(e);for(;n.length&&o(e)-o(n[n.length-1])<36;)n.pop();return[...n,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&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/I*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:v(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],S=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?.(M(s)))},M=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,F=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,W=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)} ${F}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${W?` ${W.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,n)=>(0,ne.jsx)(m.default,{testID:n,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,ne.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ne.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ne.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ne.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ne.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,ne.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,ne.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ne.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:F}),(0,ne.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),W?(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:W}):null]}):(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ne.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ne.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ne.jsxs)(a.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ne.jsx)(n.Defs,{children:(0,ne.jsxs)(n.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ne.jsx)(n.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ne.jsx)(n.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ne.jsx)(n.Line,{x1:ae,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.Circle,{cx:v(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ne.jsx)(n.Line,{x1:v(L.day),y1:10,x2:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:M(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:v(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ne.jsx)(b.default,{testID:"mt-axis",style:{height:H.AXIS_BAND+6,minHeight:H.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ne.jsx)(f.T,{size:H.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:v(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ne.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ne.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>S(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ne.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:M(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ne.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ne.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,ne.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>S(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,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ne.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: card + cash \u2212 card tips. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ne.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ne.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,ne.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ne.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ne.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,ne.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ne.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1430,[843,1140,1431,17,780,1184,1074,1075,1423,1343,861,1078,264,385,85,777,858,876,1210,1192,845,1159,863,1055,866,804,1183,1057,1139,1144,1145,1008,839,1149,886,899,915,1441,1442,1148,1443,1161,853,1446,1187,1208,856,1206,1031,1032,1066,1098,1397,1152,1342,1464,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."})]})}},1431,[1053,1033,805,1418,812,1432,1433,1435,1436,1437,1202,1031,1032,1008,1014,17,385,85,777,841,1438,816,862,1055,861,804,1057,858,1186,926,927,876,1439,1392,998,1440,1005,1142,892,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)},1432,[812,17,85,777,1140,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)},1433,[843,17,219,85,777,858,998,1153,1262,899,1337,1434,8]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1434,[843,1284]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1435,[17,85,777,998,1347,804,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1436,[17,85,777,998,863,1400,805,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1437,[]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1438,[17,1033,85,804,777,1259,1262,8]); -__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1439,[17,85,777,998,1367,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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),S=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>C(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>C(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>f(null),onSave:t=>{y.update(e.id,t),f(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",S(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>f(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:I,onCancel:()=>f(null),onSave:t=>{y.add(e,t),f(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>f('new')}),(0,k.jsxs)(r.Sheet,{visible:!!p,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:p?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{p&&y.remove(p.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{f.useOrderLists.getState().ensure(e)},[e]);const s=(0,f.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,f.orderSettingsOf)(e);(0,f.useOrderLists)(t=>t.settings[e]);const l=f.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),f=(0,s.privateClockVenue)(e),[p,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[S,v]=(0,n.useState)(!1),[C,I]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(f)return;v(!0),I('');const t=await(0,b.getFix)();if(v(!1),'object'!=typeof t)return void I('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),I(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:f?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),f?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),f?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:S?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:S,onPress:()=>{B()}}),C?(0,k.jsx)(r.Muted,{size:13,children:C}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:p,onChangeText:j,onBlur:()=>R(p,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(p,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),f?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"The full CookSafe log is in the food safety menu: CookSafe log."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_r(_d[5])),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},S=[1,2,3,4,5,6,0],v=['on_shift','everyone','managers','head_chef','kitchen','foh'],C=e=>e.replace(' (example)',''),I={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:C(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[v.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:C(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,f]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),p=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{f(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:S.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),p?(0,k.jsx)(r.Muted,{size:13,children:p}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!p,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>f.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1440,[812,912,17,362,385,85,777,804,1005,1006,876,1010,1011,1012,913,1068,899,1029,916,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1441,[]); -__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7])},1442,[17,385,85,777,804,1148,1441,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1443,[886,779,816,813,822,862,1039,1444,17,909,319,362,219,385,85,777,858,876,863,804,1183,1057,1220,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1444,[482,1445]); -__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}});var t={}},1445,[]); -__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.ProgressBar=L,_e.useSetupDone=F,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,T.useCtx)(6e4),n=F(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=k.SETUP_STEPS.findIndex(e=>e.id===a),s=k.SETUP_STEPS[e+1]?.id??null;return(0,R.jsx)(A,{id:a,wizard:!0,onBack:()=>l(e>0?k.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=k.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,R.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{gap:12,children:[(0,R.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsxs)(m.T,{size:20,weight:"bold",colour:C.colours.gold,children:["Set up ",t.name]}),(0,R.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,R.jsx)(L,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,R.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,R.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:C.colours.border,backgroundColor:C.colours.surface,overflow:'hidden'},children:k.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,R.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:C.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,R.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?C.colours.gold:'transparent',borderWidth:1.5,borderColor:t?C.colours.gold:C.colours.border},children:(0,R.jsx)(m.T,{weight:"bold",colour:t?C.colours.onGold:C.colours.muted,children:t?'\u2713':s+1})}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"medium",children:e.title}),(0,R.jsx)(m.Muted,{children:e.sub}),o.length?(0,R.jsxs)(m.T,{size:13,colour:C.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,R.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=A,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return V}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=F(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,R.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",colour:C.colours.gold,children:"Finish setting up"}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]}),(0,R.jsx)(L,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,R.jsxs)(m.Muted,{size:13,children:["Next: ",k.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]),M=_r(_d[29]),R=_r(_d[30]);const I=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=[1,2,3,4,5,6,0],B=/^([01]\d|2[0-3]):[0-5]\d$/,D=e=>{const s=(0,M.parseMoneyInput)(e);return null!=s&&s>0?Math.round(100*s):null},O=e=>k.SETUP_STEPS.findIndex(s=>s.id===e)+1;function L({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,R.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,R.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:C.colours.gold,borderRadius:5}})}),(0,R.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function F(e){const s=(0,k.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=k.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:k.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function A({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,T.useCtx)(6e4),l=F(a),r=l.prog,d=(0,i.useLiveVenue)(),u=k.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=N[e];return(0,R.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsxs)(m.T,{size:12,weight:"semibold",colour:C.colours.gold,children:["STEP ",O(e)," OF ",k.SETUP_STEPS.length]}),s&&o?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,R.jsx)(m.T,{size:13,colour:C.colours.muted,children:"All steps"})}):null]}),(0,R.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,R.jsx)(L,{done:r.done,total:r.total})]}),(0,R.jsx)(b,{rid:a,done:(t="Saved.")=>{k.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,R.jsx)(m.Banner,{kind:"success",title:p}):null,(0,R.jsx)(G,{rid:a,id:e,title:u.title,onDone:x}),s?(0,R.jsxs)(m.Row,{gap:10,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,R.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const U=({wizard:e,onPress:s,disabled:t,label:n})=>(0,R.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const _=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function W({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,T.useHourly)(),d=(0,k.useSiteSetup)(e),u=(0,k.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,f]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,S.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,k.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),f(null)},z=!!p?.id&&(E=p.id,w.ROSTER.some(e=>e.id===E));var E;const M=p?D(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=M||z&&!p.wage);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,R.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,R.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?C.colours.gold:C.colours.border,backgroundColor:s?'#1d1a14':C.colours.surface}),children:[(0,R.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"semibold",children:e.name}),(0,R.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,k.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,R.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,k.accessOf)(e.level,e.role)})]},e.id))}),y?(0,R.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:C.colours.gold},children:(0,R.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,R.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,R.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,R.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,R.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,R.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Access level"}),(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:k.ACCESS_LEVELS.map(e=>(0,R.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,R.jsxs)(m.Muted,{size:13,children:["Uses the ",k.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Pay"}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,R.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,R.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,R.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,R.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,S.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,R.jsx)(m.Field,{money:!0,label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=M&&M<1271?(0,R.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,R.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,R.jsxs)(m.Row,{gap:8,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,R.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),k.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:k.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=M&&s.setRate(t,M);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),k.useSetup.getState().patch(e,{staffGrade:o}),k.useSetup.getState().setLook(t,p.look),f(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,R.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,R.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(_(d.grades[0]?.id??'')),f(null)}}),(0,R.jsx)(U,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const N={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,k.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,R.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,R.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,R.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,R.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':(0,y.builtInLogoCopy)(e)," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,R.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,R.jsx)(z.OrderAtTableCard,{rid:e,compact:!0}),u?(0,R.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,R.jsx)(U,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,T.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=$.filter(e=>{const s=n[e];return s&&(!B.test(s[0])||!B.test(s[1]))});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),I.map((e,s)=>{const t=$[s],l=n[t];return(0,R.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:C.colours.border,paddingTop:s?6:0},children:[(0,R.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,R.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"to"}),(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,R.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,R.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries($.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,R.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,R.jsx)(U,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,f.usePlan)(e),o=(0,f.planCounts)(n);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P.TablePlan,{startStep:"areas"}),(0,R.jsx)(U,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,R.jsx)(W,{...e,payList:!0})]})},staff:W,permissions:function({done:e,wizard:s}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E.PermissionsScreen,{}),(0,R.jsx)(U,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,k.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,R.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,R.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,R.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,R.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,R.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,R.jsx)(U,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),a=(0,k.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,v.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,R.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,R.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:C.colours.border,padding:10},children:(0,R.jsx)(m.T,{size:14,colour:C.colours.goldLight,children:i})}),(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,v.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,R.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,R.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,R.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,R.jsx)(U,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),k.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,T.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,R.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,R.jsx)(U,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},V=e=>function(){return(0,R.jsx)(A,{id:e})};function G({rid:e,id:s,title:t,onDone:n}){const o=F(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,R.jsxs)(g.default,{style:{gap:4},children:[(0,R.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),k.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,R.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,R.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1446,[888,887,813,812,1039,1447,1448,1449,1450,1452,17,385,85,857,884,777,858,876,1453,998,886,878,851,804,1057,1454,1457,1461,1462,840,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1447,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1448,[17,899]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1449,[17,831,899]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1450,[880,812,17,219,366,85,777,1451,899,804,1187,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1451,[]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1452,[17,385,777,899,804,1450,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.builtInLogoCopy=function(o){return'anchorage'===o?'The Anchorage logo in black and gold.':'Placeholder initials.'}},1453,[]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1454,[812,891,1140,899,780,1229,1231,17,264,362,219,385,85,409,864,777,858,1240,876,851,863,804,1183,1057,853,1055,1443,1160,1455,1456,1139,1145,1144,1008,839,1142,1148,1220,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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1455,[812,17,1227,1026,854,362,385,85,777,876,851,863,804,1183,1057,1220,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1456,[978,17,385,85,777,876,804,1057,1160,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1457,[812,17,1018,378,85,1108,1109,1365,1397,777,995,998,863,804,1057,999,1458,1459,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1458,[812,17,385,85,777,804,998,805,999,856,899,8]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1459,[17,85,777,998,1460,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1460,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1461,[805,1418,17,85,777,858,876,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.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 ')}},1462,[17,264,385,85,777,804,915,1463,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.'},1463,[928,899,876,856,915]); -__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 P}}),_e.useInsightsAccess=S,_e.SuperProInsights=_,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,D.jsx)(o.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,D.jsx)(_,{go:e})}):(0,D.jsx)(E,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.sales)return(0,D.jsx)(E,{});const r=i.sales;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Last 7 days"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=r.last7?(0,x.moneyGbp)(r.last7):'\u2014'}),r.missing7?(0,D.jsx)(l.Muted,{center:!0,children:`From ${r.days7} of ${r.days7+r.missing7} cash ups. ${r.missing7} ha${1===r.missing7?'s':'ve'} no card or cash total yet, so ${1===r.missing7?'it is':'they are'} not in the total.`}):null,(0,D.jsx)(l.Muted,{center:!0,children:null!=r.prev7?`The 7 days before: ${(0,x.moneyGbp)(r.prev7)}${null!=r.changePct?` (${r.changePct>=0?'up':'down'} ${Math.abs(r.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,D.jsx)(l.Muted,{center:!0,children:null!=r.sph7?`Spend per head ${(0,x.moneyGbp)(r.sph7)}, on the ${r.sphDays7} day${1===r.sphDays7?'':'s'} with takings and Covers`:'Spend per head shows once days have takings and Covers'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Takings by week"}),(0,D.jsx)(O,{values:r.weeks.map(e=>e.gross),w:300,h:70}),r.weeks.slice().reverse().map(e=>(0,D.jsx)(W,{a:`${(0,w.ukDate)(e.from)} \u2013 ${(0,w.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up${e.missing?`, ${e.missing} with no card or cash total`:''}`:e.missing?`Not enough data: ${e.missing} cash up${1===e.missing?'':'s'} with no card or cash total`:'No signed-off cash ups'},e.to)),(0,D.jsx)(l.Muted,{center:!0,children:"Takings are card + cash \u2212 card tips from signed-off cash ups (Gross only for a prepaid function), as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,D.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.stock)return(0,D.jsx)(E,{});const r=i.stock;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Low or out now"}),(0,D.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."}),r.low.length?r.low.map(e=>(0,D.jsx)(W,{testID:`low-${e.key}`,tone:e.out?k.colours.red:k.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,D.jsx)(l.Muted,{center:!0,children:r.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:`Price rises in the last ${w.RISE_DAYS} days`}),r.rises.length?r.rises.map(e=>(0,D.jsx)(W,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,$.gbp)(e.before)} \u2192 ${(0,$.gbp)(e.after)} a pack \xb7 ${(0,w.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,D.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,D.jsx)(l.Muted,{center:!0,children:r.lastCount?`Last full stock count ${(0,w.ukDate)(r.lastCount)}.`:'No full stock count yet.'})]}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.gp)return(0,D.jsx)(E,{});const r=i.gp;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,D.jsx)(A,{example:i.example}),i.example?(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:k.colours.gold,children:L(r.menu)}),null!=r.startMenu&&null!=r.menu?(0,D.jsx)(l.Muted,{center:!0,children:`${G(r.menu-r.startMenu)} points since ${(0,w.ukDate)(r.trend[0]?.week??'')}`}):null,(0,D.jsx)(O,{values:r.trend.map(e=>e.menu),w:300,h:80})]}):null!=r.menu?(0,D.jsx)(v.GpOverTime,{rid:s}):(0,D.jsx)(o.default,{testID:"insights-gp-not-enough",style:{width:'100%'},children:(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP"}),(0,D.jsx)(l.T,{weight:"semibold",center:!0,children:"Not enough data"}),(0,D.jsx)(l.Muted,{center:!0,children:`${r.fullyCosted} of ${r.costed} costed dishes have every recipe ingredient costed. Menu GP shows once ${w.MIN_FULLY_COSTED} or more are, so a part-costed dish cannot make GP look too high.`})]})}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),r.drops.length?r.drops.map(e=>(0,D.jsx)(W,{testID:`drop-${e.dishId}`,tone:k.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,w.ukDate)(e.date)}`},e.dishId)):(0,D.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Each dish over 3 months"}),r.dishes.length?r.dishes.map(e=>(0,D.jsx)(W,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const s=S(),n=C(),{list:i,source:r}=N(),[a,d]=(0,t.useState)('all');if(!s.clock)return(0,D.jsx)(E,{});const c='unsigned'===a?i.filter(e=>!1===e.signed):i,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,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,D.jsx)(A,{example:!!n}),(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${i.length})`,onPress:()=>d('all'),testID:"clock-filter-all"}),(0,D.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${i.filter(e=>!1===e.signed).length})`,onPress:()=>d('unsigned'),testID:"clock-filter-unsigned"})]}),(0,D.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:c.length?c.map(e=>(0,D.jsxs)(o.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${w.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,w.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:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?k.colours.amber:k.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,w.ukDate)(e.workDate)}`}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,children:`${w.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,D.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,D.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,D.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,D.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${w.CLOCK_DAYS} days.`})}),(0,D.jsx)(l.Muted,{center:!0,children:'server'===r?'From the server\u2019s timesheet audit.':'synced'===r?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=_r(_d[1]),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=e(i),l=_r(_d[5]),a=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),$=_r(_d[15]),x=_r(_d[16]),w=_r(_d[17]),b=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),D=_r(_d[23]);const P='SuperPro';function S(){const{role:e}=(0,j.useCtx)(6e4),s=(0,j.useSignedIn)(),t=(0,j.useInStaffApp)();return(0,w.insightsAccess)({viewRole:e,signed:s,live:(0,b.isLive)(),inStaffApp:t,perm:e=>(0,b.can)(e)})}function C(){return(0,y.useExamples)()&&!(0,b.isLive)()?I.INSIGHTS_SAMPLE:null}function N(){const e=C(),s=(0,h.useOwner)(e=>e.attendance),n=(0,h.useOwner)(e=>e.staff),[o,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(e||!(0,b.isLive)())return;let s=!0;return(0,b.readClockChanges)(w.CLOCK_DAYS).then(e=>{s&&e&&i((0,w.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,t.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const t=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:t(o),source:'server'};const i=(0,w.addDaysYmd)((new Date).toISOString().slice(0,10),-w.CLOCK_DAYS);return{list:t((0,w.clockChangesFromAttendance)(s,i)),source:'synced'}},[e,o,s,n])}function M(e){const s=C(),[n,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(s||!e||!(0,b.isLive)())return;let t=!0;return(0,b.readLoyaltyInsight)().then(e=>{t&&o(e?(0,w.loyaltyInsight)(e.raw,e.source):null)}),()=>{t=!1}},[s,e]),s?s.loyalty:e&&(0,b.isLive)()?n:null}function T(e,n){const o=C(),i=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,a.useBookings)(e),y=(0,a.useOrders)(e),$=(0,d.useReviews)(e=>e.reviews),x=(0,h.useOwner)(e=>e.attendance),b=(0,j.useHourly)(),k=(0,u.useGpCalcView)(),v=(0,a.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),D=(0,g.useShellStore)((0,f.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,t.useMemo)(()=>{if(o)return{example:!0,...o};const t=v.map(e=>({id:e.id,dish:e.dish,price:e.price,ingCount:Array.isArray(e.ingredients)?e.ingredients.length:void 0})),a=new Date,d=(0,w.salesInsight)(i,l,e,n,(0,s.coverOverridesFor)(e)),c=x.filter(e=>!e.voided&&'confirmed'===(0,h.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,j.paidMins)(e,a).paid,ratePence:b[e.staffId]??0})),u=x.filter(e=>!e.voided&&'awaiting'===(0,h.attStatus)(e)).map(e=>e.date);return{example:!1,sales:d,stock:(0,w.stockInsight)((I??[]).filter(e=>!e.group),D,(s,t)=>(0,p.fmtStockCount)(e,s,t),k.ingredients,Object.values(k.counts??{}),n),gp:(0,w.gpInsight)(k.ingredients,k.cardCosts??{},t,k.settings,Object.values(k.deliveries??{}),n),bookings:(0,w.bookingsInsight)(l,e,n),orders:(0,w.ordersInsight)(y,e,n),reviews:(0,w.reviewsInsight)($,e,n),labour:(0,w.labourInsight)(c,i,e,n,u),salesReport:(0,w.salesReportInsight)(r,e)}},[o,i,r,l,y,$,x,b,e,n,k,v,I,D])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,G=e=>`${e>0?'+':''}${e.toFixed(1)}`;function O({values:e,w:s=220,h:t=44,testID:n}){const l=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(l.length<2)return null;const a=Math.min(...l.map(e=>e.v)),d=Math.max(...l.map(e=>e.v))-a||1,c=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/d*(t-12),h=l[l.length-1];return(0,D.jsx)(o.default,{testID:n,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,D.jsxs)(r.default,{width:s,height:t,children:[(0,D.jsx)(i.Polyline,{points:l.map(e=>`${c(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:k.colours.gold,strokeWidth:2.5,fill:"none"}),(0,D.jsx)(i.Circle,{cx:c(h.i),cy:u(h.v),r:3.5,fill:k.colours.gold})]})})}function R({title:e,big:s,line:t,tone:o,onPress:i,testID:r,children:a,a11y:d,plan:c}){return(0,D.jsxs)(n.default,{testID:r,accessibilityRole:"button",accessibilityLabel:d,accessibilityHint:"Opens the detail",onPress:i,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??k.colours.gold,backgroundColor:e?k.colours.goldTint:k.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:e}),c?(0,D.jsx)(l.T,{size:11,weight:"semibold",colour:k.colours.goldLight,center:!0,children:c.toUpperCase()}):null,(0,D.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??k.colours.text,children:s}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.muted,children:t}),a,(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.goldLight,children:"Open \u203a"})]})}function A({example:e}){return(0,D.jsxs)(o.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.T,{size:20,weight:"bold",colour:k.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,D.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,D.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function B({title:e,sub:s,children:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.Badge,{kind:"gold",label:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]}),(0,D.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function _({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t),r=N(),l=M(n.loyalty);if(!n.any)return null;const a=(0,w.clockSummary)(r.list),d=(0,w.loyaltyLine)(l),c=s=>e('more',s),u=i.sales,h=i.stock,g=i.gp,p=i.bookings,f=i.orders,y=i.reviews,b=i.labour,v=i.salesReport,I=e=>w.INSIGHT_PLAN[e],C=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=n.sales||n.stock||n.gp||n.clock,E=n.bookings||n.noshows||n.orders||n.loyalty||n.reviews||n.labour||n.salesReports;return(0,D.jsxs)(o.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,D.jsx)(A,{example:i.example}),_?(0,D.jsxs)(B,{testID:"insights-group-superpro",title:P,sub:"Connected EPOS insights",children:[n.sales?(0,D.jsx)(R,{plan:I('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>c('insights-sales'),big:C(u.last7),line:null==u.last7?u.missing7?`Not enough data: ${u.missing7} cash up${1===u.missing7?'':'s'} in the last 7 days ha${1===u.missing7?'s':'ve'} no card or cash total`:'No signed-off cash ups in the last 7 days':`Last 7 days, card + cash \u2212 card tips from ${u.days7}${u.missing7?` of ${u.days7+u.missing7}`:''} cash-up day${u.days7+u.missing7===1?'':'s'}${u.missing7?` (${u.missing7} with no card or cash total)`:''}${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)}`:u.missing7?'Not enough data, the cash ups have no card or cash total':'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,D.jsx)(O,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,n.stock?(0,D.jsx)(R,{plan:I('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>c('insights-stock'),tone:h.low.length?k.colours.amber:void 0,big:h.low.length?`${h.low.length} low`:h.tracked?'None low':'\u2014',line:`${h.low.length?h.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):h.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${h.rises.length} price rise${1===h.rises.length?'':'s'} in ${w.RISE_DAYS} days`,a11y:`Stock. ${h.low.length} tracked items low or out. ${h.rises.length} price rises in ${w.RISE_DAYS} days`}):null,n.gp?(0,D.jsx)(R,{plan:I('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>c('insights-gp'),tone:g.drops.length?k.colours.amber:void 0,big:null==g.menu?'\u2014':L(g.menu),line:null==g.menu?`Not enough data: ${g.fullyCosted} of ${g.costed} costed dishes have every ingredient costed`:`Menu GP, ${g.fullyCosted} fully costed dishes${null!=g.startMenu?` \xb7 ${G(g.menu-g.startMenu)} pts in 3 months`:''} \xb7 ${g.drops.length} dish${1===g.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(g.menu)}. ${g.drops.length} dishes fell after a cost change`,children:(0,D.jsx)(O,{testID:"insight-gp-spark",values:g.trend.map(e=>e.menu)})}):null,n.clock?(0,D.jsx)(R,{plan:I('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>c('insights-clock'),tone:a.unsigned?k.colours.amber:void 0,big:String(a.total),line:`Edits in ${w.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 ${w.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,D.jsxs)(B,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[n.salesReports?(0,D.jsx)(R,{plan:I('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:C(v.gross),line:v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}${v.top.length?` \xb7 ${v.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}, ${C(v.gross)}`:'None yet')}):null,n.bookings?(0,D.jsx)(R,{plan:I('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,n.noshows?(0,D.jsx)(R,{plan:I('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?k.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}${n.sales?` (${(0,$.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,n.orders?(0,D.jsx)(R,{plan:I('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,$.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,n.reviews?(0,D.jsx)(R,{plan:I('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:y.low30?k.colours.amber:void 0,big:null!=y.avg30?`${y.avg30.toFixed(1)} \u2605`:'\u2014',line:`${y.count30} review${1===y.count30?'':'s'} in 30 days \xb7 ${y.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${y.avg30??'none'} stars from ${y.count30} reviews in 30 days`}):null,n.loyalty?(0,D.jsx)(R,{plan:I('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:d.big,line:d.line,a11y:`Loyalty. ${l?.members??'Not known'} members. ${l?.stampsMonth??'Not known'} stamps this month. ${l?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,n.labour?(0,D.jsx)(R,{plan:I('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=b.pct7&&b.pct7>35?k.colours.amber:void 0,big:null!=b.pct7?`${b.pct7}%`:'\u2014',line:null!=b.pct7?`Wages of takings on the ${b.days7} day${1===b.days7?'':'s'} with takings, last 7 days \xb7 ${C(b.labour7)} wages`:`Not enough data: no day in the last 7 has both signed-off hours and takings \xb7 ${b.paidHours7} signed-off hours`,a11y:`Wages and hours versus takings. ${b.pct7??'Not known'} percent over 7 days, ${b.paidHours7} hours`}):null]}):null]})}function E(){return(0,D.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function W({a:e,b:s,tone:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]})}},1464,[1465,17,385,85,780,777,858,1242,1008,905,876,895,897,864,1145,851,1466,1468,899,804,1057,1179,1469,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"coverOverridesFrom",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"coverOverridesFor",{enumerable:!0,get:function(){return c}});var o=r(_d[0]);const t={anchorage:{'2026-11-09':{covers:50,why:'BBC function, prepaid, 50 people (Gordon, 25 Nov 2026)'}}},n=(o,n)=>n?Object.fromEntries(Object.entries(t[o]??{}).map(([o,t])=>[o,t.covers])):{},c=t=>n(t,o.LIVE_VENUE_BUILD)},1465,[822]); -__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=l,_e.previousRange=function(e,n){const o=l(e,n);if('today'===n||'week'===n)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===n?1:0)-('today'===n?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===n?1:0)-('today'===n?1:0))};const[r,s]=o.from.split('-').map(Number),u=`${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=`${u.slice(0,7)}-${o.to.slice(8,10)}`;return{from:u,to:d<=c&&d>=u?d:c}},_e.changePct=function(t,e){return null==t||null==e||0===e?null:Math.round((t-e)/e*1e3)/10},_e.changeWords=function(t,e){if(null==t)return null;const n='today'===e?'yesterday':'week'===e?'last week':'last month';return 0===t?`No change vs ${n}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${n}`},_e.canSeeTakingsStats=function(t,e,n){return!('owner'!==t&&'manager'!==t||e&&!n)},_e.coversInRange=function(t,e){let s=0,l=0;for(const u of t){if(!u.date||!n(u.date,e))continue;if(!r(u.status))continue;const t=u.partySize||0;o(u)?s+=t:l+=t}const u=s+l;if(!u)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/u*100);return{total:u,walkIns:s,bookings:l,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,e,r){const l=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t)&&(s(t.status)||'noshow'===t.status));if(!l.length)return{rate:null,count:0,of:0,empty:!0};const u=l.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/l.length*1e3)/10,count:u,of:l.length,empty:!1}},_e.cancelRate=function(t,e,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const l=s.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(l/s.length*1e3)/10,count:l,of:s.length,empty:!1}},_e.takingsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{gross:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{gross:null,days:0,missing:u.length,missingDates:u}},_e.grossDays=u,_e.tipsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.combinedTips)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{tips:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{tips:null,days:0,missing:u.length,missingDates:u}},Object.defineProperty(_e,"completeTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"missingWords",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"takingsMissingWords",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return g}}),_e.tipsVsTakings=function(e,o,r){let s=0,l=0,u=0;for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals),d=(0,t.combinedTips)(c.vals);null==e||null==d||e<=0||(s+=d,l+=e,u+=1)}return u?{pct:g(Math.round(100*s)/100,Math.round(100*l)/100),days:u}:{pct:null,days:0}},_e.spendPerHeadInRange=function(t,n,o,r,s={}){const l=[...u(t,o,r).entries()].map(([t,r])=>({date:t,gross:r,covers:(0,e.coversOn)(n,o,t)+(s[t]??0)})),c=l.filter(t=>t.covers>0),d=l.length-c.length;if(!c.length)return{sph:null,covers:0,gross:null,days:0,noCovers:d};const f=Math.round(100*c.reduce((t,e)=>t+e.gross,0))/100,g=c.reduce((t,e)=>t+e.covers,0);return{sph:Math.round(f/g*100)/100,covers:g,gross:f,days:c.length,noCovers:d}},_e.labourCostInRange=h,_e.labourVsTakings=function(t,e,n,o,r){const s=u(n,o,r),l=s.size?Math.round(100*[...s.values()].reduce((t,e)=>t+e,0))/100:null,c=s.size?h(t,r,s):null;return{pct:m(c,l),labour:c,gross:l,days:s.size,awaiting:e.filter(t=>s.has(t)).length,labourAll:h(t,r)}},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return m}}),_e.repeatGuestPct=function(t,e,o){const r=new Set;for(const n of t){if(o&&n.restaurantId!==o)continue;if(!s(n.status)||n.date>=e.from)continue;const t=p(n);t&&r.add(t)}const l=new Set;let u=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!n(d.date,e))continue;const t=p(d);t&&!l.has(t)&&(l.add(t),u+=1,r.has(t)&&(c+=1))}return u?{rate:Math.round(c/u*1e3)/10,count:c,of:u,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.firstVisitDate=function(t,e){let n=null;for(const o of t)e&&o.restaurantId!==e||!s(o.status)||!o.date||(!n||o.date(null==t.status||'published'===t.status)&&n(t.createdAt.slice(0,10),e)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,e)=>t+e.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"NOT_SHOWN_YET",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return e.coversOn}});var t=_r(_d[0]),e=_r(_d[1]);const n=(t,e)=>t>=e.from&&t<=e.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function l(e,n){return'today'===n?{from:e,to:e}:'week'===n?{from:(0,t.weekStartOf)(e),to:e}:{from:`${e.slice(0,7)}-01`,to:e}}function u(e,o,r){const s=new Map;for(const l of e){if(l.rid!==o||!l.confirmedAt||!n(l.date,r))continue;const e=(0,t.tillTakingsOf)(l.vals);null!=e&&s.set(l.date,e)}return s}const c=(t,e)=>t.missing?null:e,d=(t,e,n)=>`Not enough data: ${t} cash up${1===t?' has':'s have'} no ${e} yet (${n.map(v).join(', ')})`,f=t=>`${t.length} cash up${1===t.length?' has':'s have'} no card or cash total yet (${t.map(v).join(', ')}), so ${1===t.length?'it is':'they are'} not in the total`,g=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function h(t,e,o){let r=0,s=!1;for(const l of t)!n(l.date,e)||l.ratePence<=0||l.paidMins<=0||o&&!o.has(l.date)||(r+=l.paidMins/60*l.ratePence,s=!0);return s?Math.round(r)/100:null}const m=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function p(t){const e=(t.phone||'').replace(/\s+/g,'').toLowerCase(),n=(t.email||'').trim().toLowerCase();return e.length>=7?`p:${e}`:n.includes('@')?`e:${n}`:null}const y='Not shown yet: GP and food cost %, table occupancy and top dishes. They need till sales, which CoverCharge does not have yet.',b={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.'},k=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,v=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,w=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1466,[839,1467]); -__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,u={}){const l=(0,r.weekStartOf)(o);return Array.from({length:d},(f,h)=>{const m=(0,r.addDaysYmd)(l,7*(h-d+1)),p=i(n,t,s,(0,r.addDaysYmd)(m,6),7,u).filter(r=>r.date<=o&&null!=r.gross),v=p.length?Math.round(100*p.reduce((r,n)=>r+n.gross,0))/100:null,y=p.reduce((r,n)=>r+n.covers,0);return{weekStart:m,gross:v,covers:y,days:p.length,sph:c(v,y)}})},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,l={}){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,h)=>{const m=(0,r.addDaysYmd)(o,h-i+1),p=f.get(m)?.vals??{},v=(0,r.tillTakingsOf)(p),y=d(t,s,m)+(l[m]??0),b=u(p.food),k=u(p.drink);return{date:m,gross:v,covers:y,sph:c(v,y),food:b,drink:k,foodPh:c(b,y),drinkPh:c(k,y)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.tillTakingsOf)(n.vals))},1467,[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=d,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return c}}),_e.salesInsight=function(e,t,r,o,s={}){const a={from:d(o,-6),to:o},i={from:d(o,-13),to:d(o,-7)},l=(0,n.takingsInRange)(e,r,a),c=(0,n.takingsInRange)(e,r,i),u=(0,n.spendPerHeadInRange)(e,t,r,a,s),f=u.sph,g=[];for(let t=7;t>=0;t--){const s=d(o,-7*t),a=d(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});g.push({from:a,to:s,gross:i.gross,days:i.days,missing:i.missing})}const p=null!=l.gross&&null!=c.gross&&c.gross>0&&!l.missing&&!c.missing?Math.round((l.gross-c.gross)/c.gross*1e3)/10:null;return{last7:l.gross,prev7:c.gross,changePct:p,days7:l.days,missing7:l.missing,sphDays7:u.days,sph7:f,weeks:g,empty:g.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=d(s,-30),c=[];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&&c.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})}c.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:c,lastCount:u?.date??null,empty:!a.length&&!c.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"MIN_FULLY_COSTED",{enumerable:!0,get:function(){return g}}),_e.fullyCostedIds=p,_e.gpInsight=function(n,r,o,s,a,i){const l=p(n,r,o,s),c=o.filter(e=>(r[e.id]?.lines?.length??0)>0).length;if(l.sizel.has(e.id)),f=(0,e.menuGp)(n,r,u,s),m=(0,e.gpHistory)(a,f,'3m',i),h=m.points.find(e=>null!=e.menu)?.menu??null,b=f.dishes.map(e=>{const t=m.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)),k=(0,t.marginDrops)(a,d(i,-14)).filter(e=>u.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{fullyCosted:l.size,costed:c,menu:f.menu,startMenu:h,trend:m.points.map(e=>({week:e.week,menu:e.menu})),dishes:b,drops:k,underTarget:f.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?b(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return y(n)},_e.clockChangesFromServer=function(e){return y(e.filter(e=>h.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:k(e.action,e.old_value),after:k(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 w}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:d(r,-6),to:r},a={from:d(r,-13),to:d(r,-7)},i={from:d(r,-29),to:r},l=(0,n.coversInRange)(o,s),c=(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:c.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=d(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:d(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,o,s=[]){const a={from:d(o,-6),to:o},i=(0,n.labourVsTakings)(e,s,t,r,a),l=e.filter(e=>e.date>=a.from&&e.date<=a.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:i.labour,takings7:i.gross,pct7:i.pct,days7:i.days,paidHours7:Math.round(l/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=v(e.members),r=v(e.stampsMonth),o=v(e.rewardsUsedMonth??e.rewardsMonth),s=v(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 d(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 c=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14,g=5;function p(e,n,r,o){const s=new Set;for(const a of r){const r=n[a.id];if(!r||!r.lines?.length)continue;if(null==a.ingCount||r.lines.length0||i.priceIsSuggested||s.add(a.id)}return s}const m={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'},h=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),b=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 k(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:b(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const y=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const w=30;const v=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1468,[908,906,1466]); -__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},1469,[]); -__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.useAssistantRequestInbox=x,_e.AssistantRequestsButton=function({go:e,testID:t}){const{visible:s,count:l}=x();return s?(0,b.jsx)(n.default,{style:{width:'100%',maxWidth:900,alignSelf:'center',paddingHorizontal:14,paddingTop:4,paddingBottom:8},children:(0,b.jsx)(o.Button,{testID:t??'assistant-requests-btn',label:l?`Assistant requests \xb7 ${l}`:'Assistant requests',accessibilityLabel:(0,p.assistantRequestsButtonLabel)(l),accessibilityHint:"Opens the list of changes your assistant has asked you to confirm or decline",kind:l?'primary':'secondary',onPress:()=>e('more','assistant-requests'),style:{minHeight:56}})}):null},_e.AssistantRequestsPage=function(){const{rows:e,load:t,visible:s}=x();if(!s)return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner can confirm or decline assistant changes, and only when an assistant is paired."})]});return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{gap:12,paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Each change waits for an owner to approve or decline it. Important changes ask a second time."}),(0,b.jsx)(w,{rows:e,onChanged:()=>{t()}})]})},_e.AssistantPendingCard=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(null),c=async()=>{try{r(await(0,l.assistantProposalsList)())}catch{r([])}};return(0,t.useEffect)(()=>{if(!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR)return;c();const t=setInterval(()=>{c()},2e4);return()=>clearInterval(t)},[e,s,n]),!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR?null:(0,b.jsx)(w,{rows:o,onChanged:()=>{c()},compact:!0})},_e.AssistantsPage=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),[s,r]=(0,t.useState)(''),[u,h]=(0,t.useState)(null),[p,x]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[A,I]=(0,t.useState)(null),[k,D]=(0,t.useState)(null),[C,S]=(0,t.useState)(null),[T,P]=(0,t.useState)(null),L=async()=>{try{P(await(0,l.assistantAccess)())}catch{P({plan:null,allowed:!1,reason:'Could not check this plan.'})}try{v(await(0,l.assistantList)())}catch{v([])}try{I(await(0,l.assistantProposalsList)())}catch{I([])}try{D(await(0,l.assistantAuditList)())}catch{D([])}};(0,t.useEffect)(()=>{e&&L()},[e]);const R=s.replace(/\D/g,''),$=!!T?.allowed,M=async()=>{x(!0),h(null);const e=await(0,l.assistantApprove)(R);x(!1),e.ok?(r(''),h({ok:!0,text:'Done. The assistant is paired. It can look things up and propose changes, which wait for an owner to confirm on their phone.'}),L()):h({ok:!1,text:e.message})},q=async(e,t)=>{x(!0),h(null);const s=await(0,l.assistantSetEnabled)(e.id,t);x(!1),s.ok?(h({ok:!0,text:t?`${e.label} is switched on.`:`${e.label} is switched off. It stays paired, and you can switch it on again.`}),L()):h({ok:!1,text:s.message})};return(0,b.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,b.jsx)(w,{rows:A,onChanged:()=>{L()}}):null,(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair your assistant"}),(0,b.jsx)(o.T,{center:!0,children:f}),(0,b.jsx)(o.T,{center:!0,children:"Ask your assistant, such as Grok Bot, to start CoverCharge sign-in. It will show 6 numbers. Only an owner of this venue can approve it. In the connected assistant it can answer questions about your venue and give advice from the data it is allowed to look up. It can propose a change; nothing is changed until an owner confirms it on their 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 a second time, with a plain warning of what is affected."}),!$&&T?(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-plan-blocked",children:T.reason||'Connecting an AI assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.'}):null,(0,b.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:s,onChangeText:e=>r(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,b.jsx)(o.Button,{testID:"assistant-approve",label:p?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs your AI assistant with this venue",disabled:!e||!$||p||6!==R.length,onPress:()=>{M()},style:{minHeight:56}}),e?null:(0,b.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,b.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!u,accessibilityLabel:u?.text,children:u?(0,b.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:u.ok?c.colours.goldLight:c.colours.amber,children:u.text}):null}),(0,b.jsx)(o.Muted,{center:!0,children:"Never send a personal app link to the bot. That link stays on your phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, it cannot read other venues, and it cannot change its own access or pairing."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(t=>(0,b.jsxs)(n.default,{testID:`assistant-row-${t.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:`${t.label} \xb7 ${!1===t.enabled?'switched off':'paired'}`}),(0,b.jsx)(o.Muted,{center:!0,children:`Since ${y(t.approvedAt)}. Last seen ${y(t.lastSeenAt)}.${t.ownerName?` Tied to ${t.ownerName}.`:''}`}),(0,b.jsx)(o.Toggle,{testID:`assistant-enabled-${t.id}`,label:"Assistant on",value:!1!==t.enabled,disabled:p||!e,onChange:e=>{q(t,e)},a11y:!1===t.enabled?`Switch on ${t.label}`:`Switch off ${t.label}`}),(0,b.jsx)(o.Button,{testID:`assistant-revoke-${t.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${t.label}`,onPress:()=>S(t),style:{minHeight:56}})]},t.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Activity log"}),(0,b.jsx)(o.Muted,{center:!0,children:"Everything this venue\u2019s assistants do is logged here, including look-ups. The assistant cannot change or skip this log."}),null===k?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):k.length?k.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-audit-${e.id}`,style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:e.detail||e.action}),(0,b.jsx)(o.Muted,{center:!0,children:`${y(e.at)}${e.actorName?` \xb7 ${e.actorName}`:''}`})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-audit-empty",children:"No activity yet."})]}),C?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>S(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,b.jsx)(o.T,{center:!0,children:`${C.label} stops working straight away. Any changes still waiting are cancelled. Your phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,b.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=C;S(null);const t=await(0,l.assistantRevoke)(e.id);h(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),L()},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>S(null),style:{minHeight:56}})]}):null]})};var t=_r(d[0]),s=e(_r(d[1])),n=e(_r(d[2])),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]);const y=e=>e?`${(0,r.niceDate)(new Date(e))} at ${(0,r.hm)(new Date(e))}`:'not yet',f='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.';function w({rows:e,onChanged:r,compact:u}){const h=(e??[]).filter(e=>'pending'===e.status),[f,w]=(0,t.useState)(null),[x,j]=(0,t.useState)(null),[v,A]=(0,t.useState)(null),I=async(e,t,n=!1)=>{w(e.id),j(null);const o=await(0,l.assistantProposalDecide)(e.id,t,n);if(w(null),o.ok){A(null);const e='decline'===t?'Declined. Nothing was changed.':'Done. The change has been made.';j(e),s.default.announceForAccessibility(e),r?.()}else j(o.message),s.default.announceForAccessibility(o.message)};return!h.length&&u?null:(0,b.jsx)(n.default,{testID:u?'assistant-pending-home':'assistant-pending-list',children:(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Waiting for an owner to confirm"}),e?h.length?h.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:8,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,alignItems:'center'},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,b.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${y(e.expiresAt)}.`:'']}):e.expiresAt?(0,b.jsx)(o.Muted,{center:!0,children:`Runs out at ${y(e.expiresAt)}.`}):null,e.canDecide?(0,b.jsxs)(n.default,{style:{gap:8,width:'100%',maxWidth:520,alignSelf:'center'},children:[(0,b.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:f===e.id?'Working\u2026':'Approve',accessibilityLabel:(0,p.assistantRequestActionLabel)('Approve',e.summary),accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!f,onPress:()=>{e.needsDoubleConfirm?A(e):I(e,'approve')},style:{minHeight:56}}),(0,b.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",accessibilityLabel:(0,p.assistantRequestActionLabel)('Decline',e.summary),disabled:!!f,onPress:()=>{I(e,'decline')},style:{minHeight:56}})]}):(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner of this venue can confirm or decline this on their phone."})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,b.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),(0,b.jsx)(n.default,{accessible:!0,accessibilityLiveRegion:"polite",accessibilityRole:"text",testID:"assistant-requests-status",style:{minHeight:x?void 0:0},children:x?(0,b.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:x}):null}),v?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>A(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,b.jsx)(o.T,{center:!0,accessibilityRole:"header",children:v.summary}),(0,b.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."}),v.warning?(0,b.jsx)(o.Muted,{center:!0,children:v.warning}):null,(0,b.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:f===v.id?'Working\u2026':'Yes, make this change',disabled:!!f,accessibilityLabel:`Yes, make this change: ${v.summary}`,onPress:()=>{I(v,'approve',!0)},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Go back",accessibilityLabel:`Go back without changing: ${v.summary}`,onPress:()=>A(null),style:{minHeight:56}})]}):null]})})}function x(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(0),[c,b]=(0,t.useState)(null),y=async()=>{try{const[e,t]=await Promise.all([(0,l.assistantList)(),(0,l.assistantProposalsList)()]);r((e??[]).length),b(t??[])}catch{r(0),b([])}};(0,t.useEffect)(()=>{if('owner'!==u.APP_VARIANT||u.IS_CAR||n||'owner'!==s||!e)return;y();const t=setInterval(()=>{y()},2e4);return()=>clearInterval(t)},[e,s,n]);const f=(c??[]).filter(e=>'pending'===e.status).length;return{visible:(0,p.canSeeAssistantRequests)({appVariant:u.APP_VARIANT,isCar:u.IS_CAR,inStaffApp:n,role:s,live:e,pairedCount:o}),count:f,rows:c,load:y,paired:o}}},1470,[17,264,85,777,899,863,804,856,1057,1471,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.assistantRequestActionLabel=function(t,s){const n=String(s||'this change').replace(/\s+/g,' ').trim().replace(/\.+$/,'');return`${t}: ${n||'this change'}`},e.assistantRequestsButtonLabel=function(t){const s=Math.max(0,Math.floor(Number(t)||0));return 1===s?'Assistant requests, 1 waiting':`Assistant requests, ${s} waiting`},e.canSeeAssistantRequests=function(t){return'owner'===t.appVariant&&!t.isCar&&!t.inStaffApp&&'owner'===t.role&&!!t.live&&(t.pairedCount??0)>0}},1471,[]); -__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"})]})}},1472,[817,1189,17,264,266,347,378,219,278,85,19,777,857,860,876,998,1036,1037,805,842,1034,1473,804,856,1057,1474,1477,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}}},1473,[1034]); -__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=C,_e.importQuestionnaireAccounts=B,_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. 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)(i.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:l}=(0,x.useCtx)(6e4),j='owner'===n,I=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],M=(0,p.useQuestionnaire)(e),{mark:P}=(0,p.useProvenance)(e),[A,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(M?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!I.some(n=>n.provider===e.provider)),[M,I]),W=(M?.accounts??[]).some((e,n)=>P('accounts',n,'provider'));return(0,y.jsxs)(i.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)(i.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:P('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:l})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>M&&B(e,M,l)}):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:`${I.length}`})]}),I.length?I.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(M?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(i.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)(i.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:P('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:T[e.status].kind,label:T[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)(C,{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=I.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:A,owner:j,by:l,onClose:()=>z(null)}),$?(0,y.jsx)(k,{rid:e,c:$,by:l,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),l=e(r(d[4])),i=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)(i.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 C({rid:e,compact:n}){const{role:o,me:l}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,C]=(0,t.useState)({}),[B,I]=(0,t.useState)(null),T=u.useAccounts.getState();return(0,y.jsxs)(i.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)(i.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)(i.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)(i.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)(i.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>C({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(i.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:()=>T.update(e,o.id,{accountNo:u},l,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>I(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>T.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:l})})}),(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)}),B?(0,y.jsx)(k,{rid:e,c:B,by:l,onClose:()=>I(null)}):null]})}function k({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)(i.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:["CoverCharge will stop listing ",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 B(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const l of n.accounts??[])o.some(e=>e.provider===l.provider)||s.add(e,{provider:l.provider,handle:l.handle,status:'listed',from:'questionnaire',addedBy:t})}function I({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,C]=(0,t.useState)(p?.handle??''),[k,B]=(0,t.useState)(p?.customName??''),[I,T]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const M=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${M?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(l.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(i.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:M?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),M?(0,y.jsx)(a.Field,{label:"Service name",value:k,onChangeText:B,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:()=>T(!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."]})]}),I?(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, 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:C,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:M?'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:M&&k.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:M?k.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:M&&!k.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)(i.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)(i.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)(i.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 T={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)(I,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1474,[812,17,362,385,278,85,777,1475,1476,804,1472,1057,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)},1475,[]); -__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)}))},1476,[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})]})}},1477,[17,385,85,777,860,1476,998,842,1478,1473,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'},1478,[]); -__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}},1479,[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])},1480,[1184,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1181,1443,1161,860,1185,853,1183,884,1360,998,843,1115,1198,1205,1071,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']}},1481,[17,1055,85,409,777,858,1141,1140,861,863,804,876,1183,1057,1148,1144,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}))},1482,[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]})]})}},1483,[805,1418,843,1392,17,85,777,858,860,866,845,851,1159,1105,863,804,1183,1057,1160,1161,853,1424,848,900,1484,8]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const a=!!e.settings.takeawayPaused;return(0,u.jsx)(l.Card,{highlight:a?r.colours.red:void 0,children:(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(l.T,{weight:"semibold",children:a?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,u.jsx)(l.Muted,{children:a?'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,u.jsx)(l.Toggle,{testID:"takeaway-pause",label:a?'Resume':'Pause',value:!a,onChange:a=>t.useStore.getState().updateSettings(e.id,{takeawayPaused:!a})})]})})},_e.TakeawayMenuList=function({me:e}){const[s,t]=(0,a.useState)(!1),c=(0,o.useStaffTakeaway)(e=>e.rows),h=(0,o.useStaffTakeaway)(e=>e.canSet),f=(0,o.useStaffTakeaway)(e=>e.busy),w=(0,o.useStaffTakeaway)(e=>e.error),y=(0,o.useStaffTakeaway)(e=>e.loadedAt);(0,a.useEffect)(()=>{s&&(0,o.loadStaffTakeaway)(!0)},[s]);const k=c?Object.values(c).sort((e,a)=>e.section.localeCompare(a.section)||e.dish.localeCompare(a.dish)):null,j=k?.filter(e=>e.onMenu).length??0,x=y>0&&null===c;return(0,u.jsxs)(l.Card,{children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",k?` \xb7 ${j} of ${k.length} available`:'']}),(0,u.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Hide':'Choose dishes',onPress:()=>t(!s),testID:"takeaway-menu"})]}),s?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(l.Muted,{children:"The whole menu shows on the takeaway page. Switch off what can\u2019t be done for takeaway today: guests see it as \u201cNot available for takeaway today\u201d. A dish also needs Head Chef allergen sign-off and a price."}),!h&&k?(0,u.jsx)(l.Muted,{children:"Only the Head Chef, a manager or an owner can change this."}):null,x?(0,u.jsx)(l.Banner,{kind:"warn",children:"Connect to the venue to see the takeaway menu."}):null,w?(0,u.jsx)(l.Banner,{kind:"warn",children:w}):null,k||x||w?null:(0,u.jsx)(l.Muted,{children:"Loading\u2026"}),(k??[]).map(a=>(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsxs)(l.T,{size:14,children:[a.dish,a.pricePence?` \xb7 ${(0,d.gbp)(a.pricePence)}`:'']}),(0,u.jsxs)(l.Row,{gap:4,children:['Specials board'===a.section?(0,u.jsx)(l.Badge,{kind:"gold",label:"Special"}):null,a.soldOut?(0,u.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,a.signedOff?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),a.pricePence?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),h?(0,u.jsx)(l.Toggle,{label:"Available for takeaway",a11y:`Available for takeaway, ${a.dish}`,value:a.onMenu,disabled:f===a.itemId,onChange:s=>{(0,o.setTakeawayAvailable)(a.itemId,s,e).catch(()=>{})}}):(0,u.jsx)(l.T,{size:14,colour:a.onMenu?r.colours.gold:r.colours.muted,children:a.onMenu?'Available':'Not today'})]},a.itemId))]}):null]})};var e,a=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),t=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),u=_r(_d[7])},1484,[17,85,777,858,851,1158,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 Ce}});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]),w=_r(d[16]),v=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),I=_r(d[22]),M=_r(d[23]),G=_r(d[24]),O=_r(d[25]),E=_r(d[26]),B=_r(d[27]),x=_r(d[28]),D=_r(d[29]),N=_r(d[30]),L=(e=N)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),q=_r(d[33]),Q=_r(d[34]),F=_r(d[35]),U=_r(d[36]),V=_r(d[37]),W=_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]),ye=_r(d[64]);const Ce=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},me=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:me,C:v.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=>me(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:me,C:O.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:me,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=>me(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:me,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:me,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:me,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:me,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:me,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:me,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:me,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:E.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:me,C:G.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:me,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:B.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:B.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:me,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:me,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:me,C:w.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:B.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:B.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:B.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:me,C:B.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:me,C:B.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:me,C:B.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:me,C:B.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:me,C:B.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:B.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:me,C:B.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:B.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:()=>Ce(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:me,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:me,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:me,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:me,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:me,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:me,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const Se=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(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:Se,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:Se,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:me,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:me,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:me,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:me,C:F.DisplaySettingsPage}]);const ke=e=>'owner'===e||'manager'===e;U.ASSISTANT_AVAILABLE&&V.ASSISTANT_UI&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:ke,C:U.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:ke,C:U.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:Y.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair your own AI assistant with a 6-digit code, switch it off, or unpair it',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantsPage}]),(0,y.register)([{id:'assistant-requests',title:'Assistant requests',sub:'Confirm or decline changes your assistant has proposed',group:'Start here',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantRequestsPage}]);const we=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:I.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:I.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:I.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:I.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:I.InsightsClockPage}]);const Pe=()=>{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)},Re=e=>we(e)&&Pe();(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:we,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:Re,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:Re,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:Re,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:we,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,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:we,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:me,C:z.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:me,C:z.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:me,C:z.Outbox}]);const Ae=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:Ae,C:J.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:J.optinsAllowed,C:J.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Ae,C:$.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Ae,C:K.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:Ae,C:X.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:Ae,C:Z.OrderSheetSettings},...ee.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Ae,C:(0,K.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Ae,C:te.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Ae,C:se.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:me,C:se.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Ae,C:se.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:Ae,C:ae.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:me,C:ie.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:me,C:ie.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:me,C:ie.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:me,C:re.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos and Show me where',group:'Start here',can:me,C:oe.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:me,C:ue.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:me,C:le.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:le.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ce.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ge.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:we,C:function(){const{rid:e,today:t}=(0,de.useCtx)(6e4);return L.default.createElement(ge.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(pe.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:me,C:ne.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(he.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:me,C:be.NightlyReportPage}]),(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:ye.UseOnComputerPage}]),(0,y.register)([{id:'support',title:'Customer support',sub:'Send a message or a picture to CoverCharge',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:fe.SupportChatPage}])},1485,[822,1050,856,1486,876,920,909,816,866,1488,1495,1497,1456,1498,1499,1501,1502,1160,1481,1503,1504,1505,1464,1201,1192,1483,1506,1454,1507,1508,17,1198,1181,1455,1443,1457,1513,1213,1519,1520,1470,1521,1446,1431,1522,1461,1523,886,1524,1525,1527,1187,1472,1528,1392,1474,1540,1081,1057,1202,1152,1544,1547,1550,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}),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)}},1486,[17,378,219,385,85,19,777,1026,1339,876,804,1487,1189,1482,1057,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}))},1487,[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}},1488,[812,1452,17,851,85,777,876,804,1057,884,885,1489,899,916,1031,1450,1490,1491,1493,996,1494,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},1489,[]); -__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])},1490,[812,17,85,777,804,876,1355,1354,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])},1491,[17,85,777,1492,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},1492,[831,928,899,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]},1493,[17,85,777,804,914,1022,899,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])},1494,[928,899]); -__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 h}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LINE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LITE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_TERM",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return C}}),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 U}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return $}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),h=(0,u.trialStatus)((0,l.defaultSimStart)(),e),[y,f]=(0,t.useState)(!1);return i.CAN.billing(n)?y?(0,p.jsx)(q,{onBack:()=>f(!1)}):(0,p.jsxs)(o.default,{style:{gap:10},children:[(0,p.jsx)(s.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,p.jsxs)(s.Card,{highlight:d.colours.gold,children:[(0,p.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,p.jsxs)(s.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[S,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-early-term",children:D})]}),(0,p.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:Y.map(([e,t])=>(0,p.jsxs)(o.default,{testID:e===b?'plan-early-guest-app':e===x?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,p.jsxs)(s.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,p.jsx)(s.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,p.jsx)(s.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,N,M,z,'Usual price',''],['plan-usual-pro',E,R,U,G,'Usual price',''],['plan-superpro',k,C,F,V,'1-year contract','No hardware included.']].map(([e,t,n,l,i,u,c])=>(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,p.jsxs)(s.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsx)(s.Muted,{center:!0,children:S}),(0,p.jsx)(s.Muted,{center:!0,children:l}),'plan-superpro'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-superpro-epos-line",children:B}):null,i.map(e=>(0,p.jsxs)(s.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),'plan-usual-lite'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-lite-ai",children:I}):null,c?(0,p.jsx)(s.Muted,{center:!0,children:c}):null]})},e)),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-terms",children:$}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>f(!0),style:{alignSelf:'center'}}),(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,p.jsxs)(s.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,p.jsx)(s.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,p.jsx)(s.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,p.jsx)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{children:"Free trial"}),(0,p.jsxs)(s.T,{weight:"bold",colour:d.colours.gold,children:[h.daysLeft," day",1===h.daysLeft?'':'s'," left"]})]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-h.daysLeft/h.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,p.jsxs)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'center'},gap:8,children:[(0,p.jsx)(s.T,{weight:"semibold",children:"Free customer support"}),(0,p.jsx)(s.Badge,{kind:"gold",label:"Included"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,p.jsx)(s.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},s=r(_d[2]),l=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]);const h=!0,y='Early adopter offer, usual prices, free trial, set-up guide',f='. 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',b='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',j='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',x='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.',_='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',v='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',I='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer.',O='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',S='+ VAT if applicable, per venue',L='Customer & Takeaway App',E='Full Restaurant Pro App',k='SuperPro',N='\xa349',R='\xa399',C='\xa3149',M='The lite version: core features for smaller venues.',U='Every feature, every app.',F='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',B='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.',D='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.',Y=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',D],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[b,A],['Free customer support','For the length of your subscription.'],[x,T],[v,v],[j,w]],z=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',b,P,j],G=['Owner dashboard and admin','Supplier links',x,v,b,P,j],V=['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',_,v,b,P,j],$='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. AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',K=[['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 q({onBack:e}){const[n,l]=(0,t.useState)([]);return(0,p.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,p.jsx)(s.H2,{children:"Set-up guide"}),(0,p.jsxs)(s.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",K.length," done."]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/K.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),K.map(([e,t],i)=>{const u=n.includes(i);return(0,p.jsx)(s.Card,{children:(0,p.jsxs)(s.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.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,p.jsx)(s.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,p.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(s.T,{weight:"semibold",children:e}),(0,p.jsx)(s.Muted,{children:t}),(0,p.jsx)(s.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>l(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,p.jsx)(s.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1495,[17,85,777,835,876,1496,804,1057,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'}},1496,[]); -__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]})]})]})}},1497,[805,1033,891,1418,813,812,822,1262,1438,17,385,393,85,864,777,858,876,845,851,863,804,1183,1057,1160,1443,1220,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])},1498,[843,17,85,1161,777,858,845,853,863,804,1183,1057,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])},1499,[1039,17,85,1500,814,857,777,876,804,1057,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}})},1500,[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])},1501,[17,1154,847,1057,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])},1502,[17,1032,1057,899,915,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])},1503,[17,1398,1057,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=b,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,u.useCtx)(6e4),n=(0,o.useBookings)(e),i=(0,d.useCashUp)(e=>e.cashUps),[j,w]=(0,s.useState)('day'),f=(0,h.hasAnyTakings)(i,e),k=(0,l.coverOverridesFor)(e),v=(0,h.dayRows)(i,n,e,t,14,k),$=(0,h.weekRows)(i,n,e,t,8,k),T=(0,h.averageSph)(v),S=(e,s,t,l,n)=>(0,p.jsxs)(a.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:c.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===l?'no takings entered':`spend per head ${l}`}, ${t}${n?`, ${n}`:''}`,children:[(0,p.jsx)(r.T,{center:!0,children:s}),(0,p.jsx)(r.T,{center:!0,colour:c.colours.muted,children:t}),(0,p.jsx)(r.T,{center:!0,weight:"semibold",colour:'No takings entered'===l?c.colours.muted:c.colours.goldLight,size:'No takings entered'===l?13:16,children:l}),n?(0,p.jsx)(r.Muted,{center:!0,children:n}):null]},e);return(0,p.jsxs)(a.default,{style:{gap:12},testID:"sph-screen",children:[(0,p.jsx)(r.Muted,{children:"Tip: spend per head is takings \xf7 Covers. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,p.jsxs)(r.Card,{highlight:c.colours.gold,children:[(0,p.jsx)(r.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==T?(0,p.jsx)(r.T,{size:22,weight:"semibold",colour:c.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,p.jsxs)(r.T,{size:34,weight:"bold",colour:c.colours.goldLight,testID:"sph-avg",children:[x(T)," ",(0,p.jsx)(r.T,{size:16,colour:c.colours.muted,children:"per head"})]}),(0,p.jsx)(r.Muted,{children:f?'Only days with a cash up are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has card and cash totals.'})]}),(0,p.jsxs)(r.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(r.Chip,{testID:"sph-day",label:"By day",selected:'day'===j,onPress:()=>w('day')}),(0,p.jsx)(r.Chip,{testID:"sph-week",label:"By week",selected:'week'===j,onPress:()=>w('week')})]}),'day'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by day"}),(0,p.jsx)(b,{testID:"sph-trend-day",label:"Spend per head trend by day",points:v.map(e=>({label:y(e.date),value:e.sph}))}),[...v].reverse().map(e=>S(e.date,y(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':x(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${x(e.foodPh)}, drink ${x(e.drinkPh)} per head`:void 0))]}):null,'week'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,p.jsx)(b,{testID:"sph-trend-week",label:"Spend per head trend by week",points:$.map(e=>({label:`w/c ${y(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...$].reverse().map(e=>S(e.weekStart,`w/c ${y(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':x(e.sph)))]}):null,(0,p.jsx)(r.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=_r(_d[1]),a=e(_r(_d[2])),n=_r(_d[3]),i=e(n),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]);const x=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function b({points:e,testID:l,label:o}){const[d,h]=(0,s.useState)(320),[u,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,l]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,u)),w=Math.max(0,j-b),f=e.slice(w,j),k=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)),T=e=>38+e*(k-76)/Math.max(1,f.length-1),S=e=>140-e/$*106,L=[];let D=[];f.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} ${x(e.value)}`).join(', ');return(0,p.jsxs)(a.default,{testID:l,onLayout:e=>h(e.nativeEvent.layout.width),style:{gap:8},children:[(0,p.jsxs)(a.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,p.jsx)(i.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,p.jsx)(n.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:c.colours.muted,children:x($*e/4)},e))}),(0,p.jsxs)(i.default,{width:k,height:170,children:[[0,1,2,3,4].map(e=>(0,p.jsx)(n.Line,{x1:0,x2:k,y1:S($*e/4),y2:S($*e/4),stroke:c.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,p.jsx)(n.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:c.colours.gold,strokeWidth:2.5},s)),f.map((e,s)=>(0,p.jsx)(t.default.Fragment,{children:null==e.value?(0,p.jsx)(n.Circle,{cx:T(s),cy:140,r:2,fill:"#444"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.Circle,{cx:T(s),cy:S(e.value),r:4,fill:c.colours.goldLight}),(0,p.jsx)(n.Text,{x:T(s),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:c.colours.goldLight,children:x(e.value)})]})},w+s))]})]}),(0,p.jsx)(a.default,{style:{flexDirection:'row',gap:12},children:f.map((e,s)=>(0,p.jsxs)(a.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':x(e.value)}`,children:[(0,p.jsx)(r.T,{center:!0,size:12,colour:c.colours.muted,children:e.label}),(0,p.jsx)(r.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?c.colours.muted:c.colours.goldLight,children:null==e.value?'No takings entered':x(e.value)})]},w+s))}),(0,p.jsxs)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(r.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,p.jsx)(r.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))})]})]})}},1504,[17,1465,85,780,777,858,1008,1467,804,1057,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])},1505,[17,85,1348,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])},1506,[17,776,1057,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:a,role:I,today:x,signedIn:j}=(0,b.useCtx)(),[D,P]=(0,t.useState)('today'),R=(0,r.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),W=(0,c.useOwner)(e=>(0,c.liveAttendance)(e.attendance)),C=(0,b.useHourly)(),S=(0,$.useReviews)(e=>e.reviews),N=(0,u.canSeeTakingsStats)(I,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,v.ensureReviewSync)(e,'manage')},[e]);const M=(0,u.rangeFor)(x,D),L=(0,u.previousRange)(x,D),G=(0,t.useMemo)(()=>R.filter(s=>s.restaurantId===e),[R,e]),_=(0,u.coversInRange)(G,M),O=(0,u.coversInRange)(G,L),B=(0,u.noShowRate)(G,M,e),F=(0,u.noShowRate)(G,L,e),A=(0,u.cancelRate)(G,M,e),H=(0,u.cancelRate)(G,L,e),V='today'===D?(0,h.laterTodayCovers)(G,x):0,z=(0,u.takingsInRange)(T,e,M),U=(0,u.takingsInRange)(T,e,L),E=(0,s.coverOverridesFor)(e),Y=(0,u.spendPerHeadInRange)(T,G,e,M,E),q=(0,u.spendPerHeadInRange)(T,G,e,L,E),J=(0,u.tipsInRange)(T,e,M),K=(0,u.tipsInRange)(T,e,L),Q=(0,t.useMemo)(()=>W.filter(e=>'confirmed'===(0,c.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,b.paidMins)(e,a).paid,ratePence:C[e.staffId]??0})),[W,C,a]),X=(0,t.useMemo)(()=>W.filter(e=>'awaiting'===(0,c.attStatus)(e)).map(e=>e.date),[W]),Z=(0,u.labourVsTakings)(Q,X,T,e,M),ee=(0,u.labourVsTakings)(Q,X,T,e,L),se=(0,u.tipsVsTakings)(T,e,M),te=(0,u.firstVisitDate)(G,e),ae=(0,u.repeatGuestPct)(G,M,e),ne=(0,u.repeatGuestPct)(G,L,e),ie=(0,u.reviewAverage)(S.filter(s=>s.restaurantId===e),M),oe='today'===D?'today':'week'===D?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(o.T,{weight:"semibold",size:y.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(o.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)(o.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(o.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:D===e.id,onPress:()=>P(e.id)},e.id))}),(0,f.jsx)(w,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${oe}`,value:(0,u.pctLabel)(_.walkInPct),detail:_.empty?void 0:`${_.walkIns} walk-in covers \xb7 ${_.bookings} booked covers \xb7 ${_.total} total`,change:(0,u.changeWords)((0,u.changePct)(_.walkInPct,O.walkInPct),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${oe}`,value:(0,u.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(B.rate,F.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${oe}`,value:(0,u.pctLabel)(A.rate),detail:A.empty?void 0:`${A.count} cancelled out of ${A.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(A.rate,H.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-covers",label:`Covers \xb7 ${oe}`,value:_.empty?null:String(_.total),detail:_.empty?void 0:'today'===D?V>0?`${V} more ${1===V?'cover':'covers'} booked for later today`:'No more bookings for later today':`${_.walkIns} walk-in \xb7 ${_.bookings} booked`,change:(0,u.changeWords)((0,u.changePct)(_.empty?null:_.total,O.empty?null:O.total),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${oe}`,value:(0,u.pctLabel)(ae.rate),detail:ae.empty?void 0:`${ae.count} of ${ae.of} identifiable seated or finished parties had visited before${te?` (visits on record from ${(0,u.ukDay)(te)})`:''}`,change:(0,u.changeWords)((0,u.changePct)(ae.rate,ne.rate),D),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(w,{testID:"insights-reviews",label:`Reviews \xb7 ${oe}`,value:ie.empty?null:`${ie.avg} / 5`,detail:ie.empty?void 0:`Average of ${ie.count} published review${1===ie.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(w,{testID:"insights-tips",label:`Tips (team total) \xb7 ${oe}`,value:(0,u.moneyGbp)((0,u.completeTotal)(J,J.tips)),detail:null==J.tips?void 0:N&&null!=se.pct?`${J.days} cash-up day${1===J.days?'':'s'} \xb7 ${(0,u.pctLabel)(se.pct)} of takings on the ${se.days} day${1===se.days?'':'s'} with takings`:`${J.days} cash-up day${1===J.days?'':'s'}`,change:J.missing||K.missing?null:(0,u.changeWords)((0,u.changePct)(J.tips,K.tips),D),empty:J.missing?(0,u.missingWords)(J.missing,'tips figure',J.missingDates):'No tips entered in this period'}),N?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(w,{testID:"insights-takings",label:`Takings \xb7 ${oe}`,value:(0,u.moneyGbp)(z.gross),detail:null==z.gross?void 0:`Card + cash \u2212 card tips, from ${z.days}${z.missing?` of ${z.days+z.missing}`:''} confirmed cash-up day${z.days+z.missing===1?'':'s'}${z.missing?`. ${(0,u.takingsMissingWords)(z.missingDates)}`:''}`,change:z.missing||U.missing?null:(0,u.changeWords)((0,u.changePct)(z.gross,U.gross),D),empty:z.missing?(0,u.missingWords)(z.missing,'card or cash total',z.missingDates):'No takings entered in this period'}),(0,f.jsx)(w,{testID:"insights-sph",label:`Spend per head \xb7 ${oe}`,value:(0,u.moneyGbp)(Y.sph),detail:null==Y.sph?void 0:`\xa3${Y.gross.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})} takings \xf7 ${Y.covers} seated or finished covers, on ${Y.days} day${1===Y.days?'':'s'} with both${Y.noCovers?`. ${Y.noCovers} day${1===Y.noCovers?'':'s'} with takings and no Covers (a function, say) count${1===Y.noCovers?'s':''} in takings, not here`:''}`,change:(0,u.changeWords)((0,u.changePct)(Y.sph,q.sph),D),empty:Y.noCovers?'Spend per head needs a day with both takings and seated or finished Covers':'No takings entered, so no spend per head'}),(0,f.jsx)(w,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${oe}`,value:(0,u.pctLabel)(Z.pct),detail:null!=Z.pct?`${(0,u.moneyGbp)(Z.labour)} signed-off wages \xf7 ${(0,u.moneyGbp)(Z.gross)} takings, on the ${Z.days} day${1===Z.days?'':'s'} with takings${z.missing?`. ${z.missing} cash up${1===z.missing?'':'s'} with no card or cash total left out`:''}${Z.awaiting?`. ${Z.awaiting} shift${1===Z.awaiting?'':'s'} on those days still need${1===Z.awaiting?'s':''} signing off, not counted yet`:''}`:void 0,change:(0,u.changeWords)((0,u.changePct)(Z.pct,ee.pct),D),empty:j||Object.keys(C).length?null==Z.gross?'Not enough data: no cash up in this period has a card or cash total':'Not enough data: no signed-off hours with a pay rate on the days with takings':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(o.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-not-shown",children:(0,f.jsx)(o.Muted,{center:!0,children:u.NOT_SHOWN_YET})})]})};var e,s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=(e=a)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),y=_r(d[10]),v=_r(d[11]),$=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function w({testID:e,label:s,value:t,detail:a,change:r,empty:l}){const c=!!r&&r.startsWith('Up'),h=!!r&&r.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.Muted,{center:!0,children:s}),null==t?(0,f.jsx)(o.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:l}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.T,{testID:`${e}-value`,weight:"semibold",size:y.font.hero,colour:y.colours.gold,center:!0,children:t}),a?(0,f.jsx)(o.Muted,{center:!0,children:a}):null,r?(0,f.jsx)(o.T,{testID:`${e}-change`,center:!0,colour:c?y.colours.goldLight:h?y.colours.muted:y.colours.text,children:r}):null]})]})})}},1507,[1465,17,85,777,858,1008,876,1055,1466,899,804,1241,1242,1057,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]})}},1508,[805,1418,812,822,843,1509,1437,1487,1227,841,1262,899,1510,1512,1438,17,1098,1495,13,385,85,864,1280,777,858,876,851,866,1105,1251,863,804,1183,1057,1139,869,1456,853,1026,1154,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)},1509,[843,17,85,777,845,851,1153,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)}}})]})}},1510,[899,17,264,219,85,1280,777,1259,1262,804,1511,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},1511,[17,219,85,777,1259,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'})})}},1512,[805,1418,17,85,777,851,1259,1260,1261,899,1262,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}),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'}]},1513,[812,891,779,869,1216,17,378,219,385,278,85,831,777,1098,858,876,1514,1518,804,1057,1071,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]}})})},1514,[1515,1517,1516]); -__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)}},1515,[843,1516]); -__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'}},1516,[]); -__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}},1517,[1515,1217]); -__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},1518,[869,824,831,834]); -__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})}},1519,[17,1211,1156,1212,1224,1057,1174,847,856,993,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'},1520,[17,85,777,899,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=v,_e.SmsBubble=C,_e.AlertSettings=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=(0,p.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,p.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,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,k.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,k.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>p.useAlerts.getState().setPrefs({muted:!e})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,y.chime)('bright')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,y.lowChime)(.6)})]}),(0,k.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,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,k.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),p.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindChip,{kind:e,size:30}),(0,k.jsx)(c.default,{style:{flex:1},children:(0,k.jsx)(h.Toggle,{label:p.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>p.useAlerts.getState().setType(e,s)})})]},e))]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,k.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,k.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,k.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${p.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,p.sendTestAlert)(s,e)},e))})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,k.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,k.jsx)(h.Muted,{children:r}),(0,k.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>p.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,k.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,p.requestSystemPermission)()),p.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,p.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,k.jsx)(h.Muted,{children:(0,p.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,k.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,k.jsx)(w.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindIcon,{kind:"email"}),(0,k.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,k.jsx)(h.Badge,{kind:"neutral",label:p.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,k.jsx)(h.Muted,{children:p.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${p.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,k.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,T.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,j.templatesFor)(r),[r]),p=(0,x.useAssistant)(e=>e.enabled)&&b.ASSISTANT_UI,[y,w]=(0,n.useState)('booking'),[A,M]=(0,n.useState)('sms'),B=u[y],I=s=>m.useStore.getState().setTemplate(e,y,s),R=Object.fromEntries(j.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===y?(0,j.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,j.bookingVars)({...S,date:o},s),N=(0,j.toGsm)((0,j.fill)(B.sms,L.sms)),_=(0,j.fill)(B.subject,L.email),D=(0,j.emailHtml)((0,j.fillEmailText)(B.body,L.email),{venue:s.name,preheader:_}),O=!!r?.[y],V=s.settings;return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:j.PREVIEW_BANNER}),(0,k.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,k.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(j.DEFAULT_TEMPLATES).map(e=>(0,k.jsx)(h.Chip,{label:j.TEMPLATE_LABEL[e].title,selected:y===e,onPress:()=>w(e)},e))}),(0,k.jsx)(h.Muted,{children:j.TEMPLATE_LABEL[y].when}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,k.jsxs)(h.Muted,{children:[(0,j.smsParts)(N).chars," characters"]})]}),(0,k.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:B.sms,onChangeText:e=>I({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,j.smsParts)(N).chars>300?(0,k.jsx)(h.T,{size:13,colour:f.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,k.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:B.subject,onChangeText:e=>I({subject:e}),style:h.styles.input}),(0,k.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,k.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:B.body,onChangeText:e=>I({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,k.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[p?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>I(P(B))}):null,O?(0,k.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,y,null)}):null]}),p?(0,k.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,k.jsxs)(h.Muted,{children:["Placeholders: ",j.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:"Text",selected:'sms'===A,onPress:()=>M('sms')}),(0,k.jsx)(h.Chip,{label:"Email",selected:'email'===A,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,k.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,k.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===y?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===A?(0,k.jsx)(C,{text:N,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),_]}),(0,k.jsx)(v,{html:D})]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,k.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,k.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:V.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,k.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!V.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,k.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,T.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),b=t.filter(e=>'all'===l||e.channel===l);return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:f.colours.gold,borderRadius:12,padding:12},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:f.colours.gold,children:(0,j.isLive)()?'Live: messages are sent through your text and email service.':j.PREVIEW_BANNER}),(0,j.isLive)()?null:(0,k.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,k.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,k.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),b.length?null:(0,k.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),b.map(e=>(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,k.jsxs)(h.T,{weight:"semibold",children:[A[e.kind]," \xb7 ",e.ref]})]}),(0,k.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,k.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,k.jsx)(h.T,{size:13,colour:'sent'===e.status?f.colours.ok:'failed'===e.status?f.colours.red:f.colours.amber,children:(0,j.statusLabel)(e)})]}),'sms'===e.channel?(0,k.jsx)(C,{text:e.body}):u===e.id?(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),e.subject]}),(0,k.jsx)(v,{html:e.html??'',height:560})]}):(0,k.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,k.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]),k=_r(d[18]);function v({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 C({text:e,to:t}){const l=(0,j.smsParts)(e);return(0,k.jsxs)(c.default,{style:{gap:4},children:[t?(0,k.jsxs)(h.Muted,{children:["To ",t]}):null,(0,k.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,k.jsx)(h.T,{size:15,children:e})}),(0,k.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const S={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 P(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 A={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1521,[813,812,822,17,219,385,85,777,1229,858,1518,1213,848,1231,1018,804,1027,1057,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:n,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,b=n.settings,x=(0,r.bookingRulesOf)(n),f=(0,o.usePlan)(g),j=(f?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...b.bookingRules??{},...x,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(n),M=(0,d.depositOf)(b),R=b.reservables??(0,i.reservablesOf)(n),O=(0,r.accessGuideOf)(n),[I,A]=(0,t.useState)(null),D=(e,t)=>T({largeGroups:x.largeGroups.map((n,s)=>s===e?{...n,...t}:n)});return(0,y.jsxs)(s.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."}),I?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:I}):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:b.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)(n)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(n)} 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."}),x.largeGroups.map((e,t)=>(0,y.jsxs)(s.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=>D(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>D(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=>D(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:x.largeGroups.filter((e,n)=>n!==t)})}):null]},t)),x.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=x.largeGroups[x.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...x.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:j.map(e=>{const t=x.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(x.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:x.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)(x,n.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(x.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(x.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:x.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!==b.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:x.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),x.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,x.onlineTableMins.map((e,t)=>(0,y.jsxs)(a.Muted,{center:!0,testID:`rules-table-min-${t}`,children:[(0,r.onlineTableMinLine)(e),". Staff can still book them for fewer."]},t)),(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:b.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:M.on&&M.perPersonPence>0?`${w(M.perPersonPence)} per adult for ${M.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),R.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:x.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:x.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:x.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:x.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:x.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:x.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}),A('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:n}=(0,k.useCtx)(6e4),o=T(n),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,b.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,f.isSupabaseConfigured)())return;let e=!0;try{(0,x.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:n})=>{e&&!n&&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)(s.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,f.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,x.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:j.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),n=_r(_d[1]),s=(e=n)&&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]),b=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),j=_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(b.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()},1522,[17,85,777,858,998,1079,1055,841,1105,1251,889,876,920,899,928,971,804,1057,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)})]})]})}},1523,[17,385,85,777,876,1000,851,1001,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]})}},1524,[17,219,385,85,409,777,804,1376,857,1380,863,899,1381,1057,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})},1525,[820,896,1454,17,219,85,777,816,876,895,1000,897,899,1526,804,880,1162,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'}},1526,[]); -__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])},1527,[17,85,777,804,1433,1509,1057,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=w,_e.HelpPage=function({go:e}){const[s,o]=(0,a.useState)(''),[r,h]=(0,a.useState)(null),[p,x]=(0,a.useState)(null),w=(0,a.useMemo)(()=>[...c.HELP,...m],[]),j=(0,a.useMemo)(()=>s.trim()?(0,u.searchHelp)(w,s,10).map(e=>e.a):w.filter(e=>!r||e.topic===r),[s,r,w]);return(0,f.jsxs)(i.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(i.default,{style:[l.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(l.T,{colour:y.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:o,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:y.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(n.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>o('')}):null]}),s?(0,f.jsx)(l.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)(l.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(l.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,n)=>(0,f.jsx)(b,{a:t,go:e,open:p===t.id||!!s&&0===n&&null===p,onToggle:()=>x(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(l.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",colour:y.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(l.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(l.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=function({go:e}){const{rid:t,today:s}=(0,x.useCtx)(6e4),n={rid:t,today:s,go:(t,s)=>e(t,s??null)},[o,r]=(0,a.useState)(''),[h,u]=(0,a.useState)(null),[m,b]=(0,a.useState)(null),C=async()=>{const e=o.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,n);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...j(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(i.default,{testID:"ask-assistant",children:(0,f.jsxs)(l.Card,{highlight:y.colours.gold,children:[(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(i.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(l.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:o,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:C,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(l.Button,{label:"Ask",testID:"assistant-ask",disabled:!o.trim(),onPress:C,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(l.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)(l.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(k,{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,n,!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,m?(0,f.jsxs)(i.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(l.Banner,{kind:'done'===m.kind?'success':'error'===m.kind?'warn':'demo'===m.kind?'demo':'info',title:m.text}),m.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>w(s,e)}):null]},t)})]}):null,(0,f.jsx)(l.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),o=e(_r(d[4])),i=e(_r(d[5])),l=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),y=_r(d[12]),x=_r(d[13]),f=_r(d[14]);const m=[{id:'ai-assistant-pairing',kind:'faq',topic:'Accounts',title:'Can I connect my own AI assistant?',keywords:['assistant','ai','pair','pairing','grok','bot','unpair','approve','draft','log'],body:'AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. In the connected assistant, it can answer questions about your venue and give advice from the venue data it is allowed to look up. It can draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged, including look-ups. Open More \u203a Account \u203a Assistants, as an owner, on Full Restaurant Pro, SuperPro or the early adopter offer. It is not included with Customer & Takeaway App, and there is no AI assistant on the Display app.',showMe:{tab:'more',page:'assistants',target:{testID:'assistants-page'},hint:'Pair, switch off or unpair an assistant here. Owners only.'}},{id:'customer-support',kind:'faq',topic:'Accounts',title:'How do I contact CoverCharge support?',keywords:['support','customer support','help','email','picture','photo','screenshot','contact','covercharge'],body:'Customer support is at the very bottom of Home, and at the bottom of More, as an owner. Write a message, attach one picture if you like (a photo or a screenshot), and tap Send to CoverCharge. It is sent with your venue name, your name and email, and the app version. You will see \u201cSent. We\u2019ll reply by email.\u201d if it went through, or an error with a way to try again. There is no Customer support on the Display, Staff, Front of House or Head Chef apps.',showMe:{tab:'more',page:'support',target:{testID:'customer-support'},hint:'Write a message, attach a picture if you like, and send it to CoverCharge. Owners only.'}},{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:'In the Managers app go to More \u203a Run the day \u203a Display settings 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. There is no wipe or unpair button on the Display itself. To switch a Display off, go to Settings \u203a Displays and choose Switch off.',showMe:{tab:'more',page:'displaysettings',target:{testID:'wipe-setting'},hint:'Sign out and wipe is in Display settings, in the Managers app only.'}}];function w(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 b({a:e,go:t,open:s,onToggle:n}){return(0,f.jsx)(i.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(o.default,{accessibilityRole:"button",onPress:n,children:(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(i.default,{style:{flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(l.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(l.T,{colour:y.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(i.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(l.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>w(e,t)})}):null]})})}function j(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function k({p:e,today:t,onChange:n,onConfirm:a,onCancel:o}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>n({...e.params,[t]:s}),x=e.action,m=e.params,w=x.params.every(e=>!e.required||void 0!==m[e.name]&&''!==m[e.name]);return(0,f.jsxs)(i.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?y.colours.red:y.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':y.colours.okBg},children:[(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[x.risk]}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:x.title})]}),x.form&&'add_walkin'===x.id?(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Covers",value:void 0===m.covers?'':String(m.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Table (optional)",value:void 0===m.table?'':String(m.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,x.form&&'add_rota_shift'===x.id?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{size:12,children:"Who"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(l.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:m.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1.3},children:(0,f.jsx)(l.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(m.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Start (24h)",value:String(m.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"End (24h)",value:String(m.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(l.T,{children:w?x.preview(m,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(l.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(l.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(l.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!w,onPress:a,style:{flex:1}}),(0,f.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:o,style:{flex:1}})]})]})}},1528,[812,1033,779,17,385,85,777,876,1479,1529,1530,1531,804,1057,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.','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:'guest-change-link',kind:'faq',topic:'Bookings',title:'Can guests change or cancel their own booking?',keywords:['change','cancel','link','email','guest','move','booking'],body:'Yes. The confirmation email has a "Change or cancel your booking" link for that one booking, with "Or call us on (your number) and quote your booking details." underneath. Guests can change the date, time or party size within your online booking rules, or cancel after confirming. Bookings with a deposit say "please call us" instead. Takeaway orders can\u2019t be changed or cancelled by the guest, and their email has no link. You see every change on the Display and in Managers, marked as changed by the guest. The link stops working at the booking time.'},{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:'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 takings \xf7 Covers, by day and by week. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). 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.'},{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.'}],o=t=>a.find(a=>a.id===t)},1529,[]); -__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}},1530,[]); -__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}},1531,[1532,1100,843,1533,1534,876,858,998,1479,1529,1530,1536,1535,1538,1539,996,997]); -__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))}}]},1532,[1064,1063,1023]); -__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.`)}}]},1533,[896,1100,820,843,1121,1098,1115,922,858,816,998,895,897,1010,876,1067,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]),n=_r(_d[3]),r=_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)=>r.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(),n=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(n){const e=Number(/\d/.test(n[1])?n[1]:n[2]),a=L.indexOf(/\d/.test(n[1])?n[2]:n[1]);let r=Number(t.slice(0,4));return`${r}-${A(a+1)}-${A(e)}`e.active)){const n=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),r=Math.min(...n.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));r<1/0&&a.push({s:e,at:r})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>r.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(),n=U(e);if(!n.length)return;const r=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(r)return n.find(e=>e.number===Number(r[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=n.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===n.length?n[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const r=a.useStore.getState(),i=r.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=n.useFloor.getState(),c=d.plans[e]??(0,n.seedPlan)(e),h=r.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,r.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 n=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return n?`Seat ${Y(a)}, at table ${n}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const r=z(a.rid,e.who);if(!r)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,r.partySize);return i?(await t.repo.waitlist.setStatus(r.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,r.partySize,i,`From waitlist #${r.number}`),(0,n.tablesOf)(i).forEach(e=>n.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${r.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=r.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),n=j(String(t??''),e.today);return n?a.find(e=>e.date===n):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(),n=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(n){const e=j(n[1],t),a=j(n[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!n||e.kind===n)),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 ne(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),n=new Date(a+'T00:00:00').getTime(),r=n+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=n&&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>=n&&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)()),n=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),r=(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=>r.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),n):[];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 n;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(n?.s??0)&&(n={m:t,s:e})}return n?.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 n=z(a.rid,e.who);return n?(await t.repo.waitlist.setStatus(n.id,'removed'),`Done: number ${n.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,r)=>{const i=z(r.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===r.rid);return n.useFloor.getState().logSms(r.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?r.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(r.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),n=E(e.with);return n&&n.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(n.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),n=E(e.with);return a&&t.whoId?n&&n.id!==t.whoId?(r.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:n.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(n.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)())),n=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:n&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(n[1])?n[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=r.useOwner.getState().shifts.find(e=>e.id===t.shiftId),n=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${n}\u2019s swap with ${i}`:t.toId?`${i} covering ${n}`:`${n}\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 ${n}\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=r.useOwner.getState(),n=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)}${n?` (${M[n.day]} ${R(n.start)}\u2013${R(n.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 n=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: ${n.n} checks, ${n.bad} out of range${n.bad?`, ${n.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:n}=ne(t.today,t),r=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(r)return`This week is already signed off by ${r.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${n.entries} checks, ${n.outOfRange} out of range, ${n.actions} with an action, diary signed ${n.daysSigned} of 7 days.`;return n.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:n}=ne(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':n.actions!0),note:'Signed by voice: yes to all.',summary:n}),'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),n=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${n}; 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)),n='Near miss'===a.category,r=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(r)}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??'')||(n?'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:n,rem:r}=se(t,e.task);return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?`${_(n.text)} is already ticked today.`:`Tick off today\u2019s task ${_(n.text)}?`:r?`Mark the reminder ${_(r.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:n,rem:r}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,n.id,a,i),`Done: ${_(n.text)} ticked.`):r?(c.useReminders.getState().markDone({rid:t.rid,reminderId:r.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),r=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=n?.sections.find(e=>r.includes(e.toLowerCase())||r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=String(e.section??n?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${r} 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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(r)||r<=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??n?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:r,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 n=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 n?{dish:n[1],field:'description',value:n[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 n=de(t.rid,e.dish),r=String(e.value??'').trim();return n?r.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(n.id,'name'===e.field?{name:r}:{description:r}),'name'===e.field?`Done: renamed to ${r}.`:`Done: description of ${n.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 n=(0,$.findCard)(t.rid,a.dish);return n?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${n.dish}\u2019s recipe card?${n.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)),n=a&&(0,$.findCard)(t.rid,a.dish);return a&&n?(await(0,y.recipeCards)().update(n.id,{ingredients:[...n.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 ${n.dish}.${n.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,n=String(e.step??'').trim();return!a||n.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,n]},{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],n=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),r=/\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:r,reason:n?.[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 n=e.action??'in',r=(0,g.managerClockAction)(n,{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 r.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[n]} at ${D()}.${r.warn?' '+r.warn:''}`:'Nothing changed: '+r.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 n=h.useCashUp.getState(),r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,r?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(n.tips.filter(e=>e.rid===t.rid),n.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: 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 n='yesterday'===e.day?(0,l.ymdOf)(a):e.day,r=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!n||e.date===n)).sort((e,t)=>t.date.localeCompare(e.date)),i=r[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: takings ${fe((0,p.tillTakingsOf)(i.vals))} (card + cash \u2212 card tips), tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:n?`There\u2019s no cash-up for ${(0,$.niceDay)(n)}.`:'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 r='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,n.tablesOf)(a).forEach(e=>n.useFloor.getState().setLive(t.rid,e,{note:r||void 0})),r?`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 n=(0,$.appNow)();return r.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(n)} ${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',n=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),r=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:n?.[1]?.trim(),time:r?(0,$.hm)(r[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??''),n=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(n)}, ${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(),n=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(n))return'Nothing changed: I need the wording and a time like 21:00.';const r=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:r,time:n,audience:e.audience??'all'}),'Done: reminder added.'}}]},1534,[820,858,816,998,876,1003,1014,1015,927,926,1008,839,1034,1035,1036,1004,1067,867,1076,995,854,1535,1533]); -__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.'}}]},1535,[820,891,1100,843,1140,1262,858,816,998,1003,910,846,845,1076,1077,995,1004,851,1536,1537]); -__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)}))},1536,[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)}))},1537,[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)])},1538,[816,876,910,851,1535,1017,1071]); -__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))'},1539,[]); -__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,u.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:u.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:u.VOICE_ROLE_LABEL[s],value:(0,u.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,h.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:p}=(0,f.useCtx)(6e4),u=(0,r.useDrafts)(e=>e.drafts),h=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=u.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),D='owner'===p||'manager'===p,C=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:r.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&&D?(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'})}),C(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${C(e).name} ordering`,onPress:()=>{t.default.openURL(C(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:"Drafts saved earlier (bookings, supplier shopping lists, offers, events, specials, messages and payments) wait 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."}),D?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:()=>{h(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,p.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,p.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. 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]),r=_r(_d[6]),l=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),h=_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'}}},1540,[17,362,85,777,804,1475,1536,1487,1537,1541,1216,1542,1057,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return s}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(f(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(f(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),s=(e,n,t)=>!1!==e[n]?.[t],f=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1541,[824,831,834]); -__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])},1542,[17,85,777,804,1543,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.'},1543,[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}},1544,[17,779,85,777,845,1259,1545,1546,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'},1545,[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()})},1546,[899,1545,1262]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:l,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,o.useCashUp)(e=>e.cashUps),k=(0,o.useCashSettings)(e),w=(0,d.useNightlyPrefs)(s=>s.email[e]??!1),T=(0,d.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(s=>s.rid===e&&s.on).map(e=>e.name),[N,U]=(0,s.useState)((0,u.addDaysYmd)(v,-1)),P=(0,u.cashFieldsForRecord)(k.cashFields,(0,u.cashUpRecordFor)(e,l.settings.cashUpRecord)),R=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:P,soldOut:C}),_='anchorage'!==e&&w,D=[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:D.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:()=>U(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:R.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(R.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(R.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(R.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:R.takings}),(0,j.jsx)(x,{label:"Tips",value:R.tips}),(0,j.jsx)(x,{label:"Takings last week",value:R.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:R.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:R.soldOut.length?R.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),R.cashUp.length?R.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:_,onChange:s=>T(e,s)}):null]})};var e,s=_r(_d[0]),l=_r(_d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),d=_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:s})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${s}`,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:s})]})},1547,[17,85,777,858,1008,1548,891,839,1549,1020,804,1057,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}))},1548,[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.tillTakingsOf)(k.vals):null,N=(0,l.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:s(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(y),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(O?(0,t.tillTakingsOf)(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]),l=r(d[2]);const s=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?s(t):String(t);function u(t,l,u){const c=[];for(const f of l){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const l=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==l?'Not entered':s(l)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!l.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const l=(0,n.expectedCashInDrawer)(t);null!=l&&c.push({label:'Expected cash in the drawer',value:s(l)})}return c}},1549,[839,1009,1467]); -__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.SupportChatPage=function(){const{r:e,me:f,meId:x}=(0,h.useCtx)(6e4),[j,v]=(0,s.useState)(''),[C,I]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[R,D]=(0,s.useState)('idle'),[L,P]=(0,s.useState)(''),[k,B]=(0,s.useState)(''),[_,T]=(0,s.useState)('');(0,s.useEffect)(()=>{(0,p.signedInEmail)().then(B)},[]);const E=async e=>{T('');try{const t=await(0,c.capturePlatingPhoto)(e);t&&(I(t),D(e=>'sent'===e?'idle':e))}catch(e){T(e instanceof Error?e.message:'Could not add that picture.')}},H=async()=>{const t=j.trim();if(!t||w)return;S(!0),P(''),D('idle');const s=await(0,p.writeSupportRequest)({venueName:e.name,body:t,fromName:f.replace(' (example)',''),fromEmail:k,staffRef:x||'',appVersion:u.APP_VERSION,photoDataUrl:C?.dataUrl??null});if(S(!1),s.ok)return v(''),I(null),D('sent'),void P(b);D('error'),P(s.message)};return(0,y.jsxs)(l.default,{testID:"customer-support",style:{gap:12,alignItems:'center',width:'100%',paddingBottom:8},children:[(0,y.jsx)(o.T,{center:!0,weight:"bold",colour:n.colours.gold,accessibilityRole:"header",children:"Customer support"}),(0,y.jsx)(o.Muted,{center:!0,children:"Send a message to CoverCharge. You can attach one picture, such as a photo or a screenshot. We'll reply by email."}),'sent'===R?(0,y.jsx)(l.default,{testID:"support-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:b,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"success",title:b})}):null,'error'===R?(0,y.jsx)(l.default,{testID:"support-error",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:L,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"danger",title:L})}):null,(0,y.jsx)(t.TextInput,{testID:"support-message",accessibilityLabel:"Your message to CoverCharge",value:j,onChangeText:e=>{v(e),'sent'===R&&D('idle')},placeholder:"Write your message",placeholderTextColor:n.colours.muted,multiline:!0,style:{width:'100%',minHeight:120,borderWidth:1,borderColor:n.colours.border,borderRadius:12,padding:12,color:n.colours.text,textAlign:'center'}}),C?(0,y.jsxs)(l.default,{testID:"support-photo-preview",style:{alignItems:'center',width:'100%',gap:8},children:[(0,y.jsx)(r.default,{source:{uri:C.dataUrl},style:{width:240,height:180,borderRadius:12,backgroundColor:n.colours.surface2},accessibilityLabel:"Attached picture preview"}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Remove picture",accessibilityLabel:"Remove the attached picture",testID:"support-photo-remove",onPress:()=>I(null),style:{minHeight:48}})]}):(0,y.jsxs)(l.default,{style:{width:'100%',gap:8,alignItems:'center'},children:[(0,y.jsx)(o.Button,{kind:"secondary",label:"Take a photo",accessibilityLabel:"Take a photo to attach",testID:"support-photo-camera",onPress:()=>{E('camera')},style:{minHeight:48,width:'100%'}}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a picture or screenshot from your gallery",testID:"support-photo-gallery",onPress:()=>{E('library')},style:{minHeight:48,width:'100%'}})]}),_?(0,y.jsx)(o.Muted,{center:!0,testID:"support-photo-error",children:_}):null,(0,y.jsx)(o.Button,{testID:"support-send",label:"Send to CoverCharge",accessibilityLabel:"Send to CoverCharge",disabled:!j.trim()||w,onPress:()=>{H()},style:{minHeight:56,width:'100%'}}),w?(0,y.jsx)(l.default,{accessibilityLiveRegion:"polite",style:{width:'100%'},children:(0,y.jsx)(o.Muted,{center:!0,testID:"support-sending",children:"Sending\u2026"})}):null]})};var t=_r(d[0]),s=_r(d[1]),r=e(_r(d[2])),l=e(_r(d[3])),o=_r(d[4]),n=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),y=_r(d[10]);const b="Sent. We'll reply by email."},1550,[812,17,319,85,777,804,1082,978,1551,1057,8]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPPORT_BUCKET",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SUPPORT_SEND_FAILED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SUPPORT_SIGN_IN",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SUPPORT_NO_EMAIL",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SUPPORT_PHOTO_FAILED",{enumerable:!0,get:function(){return l}}),e.writeSupportMessage=async function(o){if(!t.RELEASE.supportSync)return{ok:!1,message:n.SUPPORT_NOT_SENT};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:n.SUPPORT_NOT_SENT};const c=u.useSync.getState().venueId;if(!c)return{ok:!1,message:`${n.SUPPORT_NOT_SENT} Sign in and try again.`};try{const t=(0,i.getSupabase)(),{error:s}=await t.from('support_messages').insert({venue_id:c,body:o.text,from_name:o.from,staff_ref:o.staffRef||null});return s?{ok:!1,message:n.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:n.SUPPORT_NOT_SENT}}},e.writeSupportRequest=async function(t){if('undefined'!=typeof globalThis&&globalThis.__CC_SUPPORT_FAKE_SEND)return{ok:!0,id:'preview-test',emailed:!0};const n=t.body.trim().slice(0,4e3),S=t.fromName.trim().slice(0,80),y=t.fromEmail.trim().slice(0,254),P=t.venueName.trim().slice(0,120);if(!n||!S||!P)return{ok:!1,message:f};if(!y||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y))return{ok:!1,message:m};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:p};const b=u.useSync.getState().venueId;if(!b)return{ok:!1,message:p};const T=globalThis.crypto?.randomUUID?.()??`00000000-0000-4000-8000-${Date.now().toString(16).padStart(12,'0')}`,O=(0,i.getSupabase)();let h=null;if(t.photoDataUrl)try{const n=_(t.photoDataUrl);h=`${b}/${T}.jpg`;const{error:o}=await O.storage.from(c).upload(h,n,{contentType:'image/jpeg',upsert:!1});if(o)return{ok:!1,message:l}}catch{return{ok:!1,message:l}}const E={id:T,venue_id:b,venue_name:P,body:n,from_name:S,from_email:y,staff_ref:t.staffRef||null,app_version:(t.appVersion||o.APP_VERSION).slice(0,40),photo_path:h},{error:N}=await O.from('support_requests').insert(E);if(N)return{ok:!1,message:f};let U=!1;try{const t=await O.functions.invoke('send-support-email',{body:{request_id:T}}),n=t.data;U=!t.error&&!!n?.sent}catch{U=!1}return{ok:!0,id:T,emailed:U}},e.signedInEmail=async function(){if(!(0,s.isSupabaseConfigured)())return'';try{const{data:t}=await(0,i.getSupabase)().auth.getUser();return(t.user?.email??'').trim()}catch{return''}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),i=r(d[4]),u=r(d[5]);const c='support-photos',f='Could not send. Check your connection and try again.',p='Could not send. Sign in and try again.',m='Your sign-in has no email. Sign in again and try again.',l='Could not attach the picture. Try a smaller photo, or send without a picture.';function _(t){const n=/^data:([^;]+);base64,(.+)$/.exec(t);if(!n)throw new Error('bad picture');const o=atob(n[2]),s=new Uint8Array(o.length);for(let t=0;t{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{}}},1552,[17,264,219,85,777,812,804,899,1428,1187,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+'},1553,[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 ']]},1555,[]); -__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:te,height:se}=(0,a.default)(),[oe,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(!1),[le,ae]=(0,t.useState)(!1),[de,ce]=(0,t.useState)(''),[ue,ge]=(0,t.useState)(!1),[he,pe]=(0,t.useState)(!1),[be,fe]=(0,t.useState)(!1),[me,xe]=(0,t.useState)(!1),ke=(0,t.useRef)(null),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(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,M.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const Ce=(0,K.useTakingsAllowed)(s),ve=(0,t.useCallback)(e=>{const t=(0,A.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),De=(0,t.useMemo)(()=>(0,V.buttonsFor)({takings:Ce,pageOk:ve}),[Ce,ve]),Ie=oe?(0,V.tabsFor)(oe.btn,{takings:Ce,pageOk:ve}):[],Se=(0,t.useCallback)((e,t)=>{const s=(0,V.tabsFor)(e,{takings:Ce,pageOk:ve});s.length&&(ie(!1),ae(!1),ce(''),ne({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[Ce,ve]),Te=De.find(e=>'settings'===e.id),Re=(0,t.useCallback)(e=>{const t=De.find(t=>t.pages.some(t=>t.id===e));t?Se(t,e):Te&&ve(e)&&(ie(!1),ae(!1),ce(''),ne({btn:Te,tab:'@desk-settings',page:e}))},[De,Se,Te,ve]),Oe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Re(t);else{if('bookings'===e){const e=De.find(e=>'bookings'===e.id);return void(e&&Se(e,'@bookings'))}if('chat'===e){const e=De.find(e=>'chat'===e.id);return void(e&&Se(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Te&&Se(Te):ne(t=>({btn:t?.btn??De[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else ne(null)},[De,Se,Re,Te]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Oe}),()=>T.useVoiceNav.setState({go:null})),[Oe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Oe('bookings'):'chat'===e?Oe('chat'):Oe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Pe=!oe||De.some(e=>e.id===oe.btn.id)&&Ie.some(e=>e.id===oe.tab)&&(!oe.page||ve(oe.page));(0,t.useEffect)(()=>{if(!Pe){const e=setTimeout(()=>ne(null),0);return()=>clearTimeout(e)}},[Pe]);const Le=oe?.page?(0,A.pageFor)(oe.page):void 0,We=oe?(0,_.deskCopy)(Le?.title??oe.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${We} \xb7 The Anchorage \xb7 CoverCharge for desktop`),we.current?.scrollTo?.({y:0,animated:!1}),oe){const e=setTimeout(()=>Y(je.current),80);return()=>clearTimeout(e)}},[We,oe?.tab,oe?.page]),(0,t.useEffect)(()=>{if(le){const e=setTimeout(()=>ke.current?.focus?.(),100);return()=>clearTimeout(e)}},[le]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=q(e.target),s=(0,_.commandKey)(e,t);if('escape'===s){if(le||ue||he||be)return e.preventDefault(),ae(!1),ge(!1),pe(!1),void fe(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return re?(e.preventDefault(),void ie(!1)):void(oe&&(e.preventDefault(),ne(null)))}if(le||ue||he||be||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),ie(!1),void ae(!0);if('help'===s)return e.preventDefault(),void ge(!0);if('filter'===s&&ye.current&&oe)return e.preventDefault(),void ye.current?.focus?.();const o=t?null:(0,_.shortcutIndex)(e);null!=o&&De[o]&&(e.preventDefault(),Se(De[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[le,ue,he,be,re,oe,De,Se]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Oe,globalThis.__deskOpen=(e,t)=>{const s=De.find(t=>t.id===e);s&&Se(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Oe,De,Se]);const Be=(0,t.useMemo)(()=>{const e=de.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De.flatMap(e=>(0,V.tabsFor)(e,{takings:Ce,pageOk:ve}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Se(e,t.id)}))),o=new Set(De.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...A.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,_.deskCopy)(e.title),sub:(0,_.deskCopy)(e.sub??''),run:()=>Re(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[de,De,s,Ce,ve,Se,Re]),He=(0,N.ddmmyyyy)(o),Me=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),Ee=b?(0,B.authorityRole)(b):s,$e=(b?.name??h).replace(' (example)',''),ze='owner'===Ee?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Ae=e=>(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Fe=e=>{const t=(0,A.pageFor)(e);return!t||t.can&&!t.can(s)?(0,X.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,X.jsx)(t.C,{go:Oe})})};return(0,X.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,X.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>oe?Y(je.current):ie(!0),children:(0,X.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:oe?'Skip to main content':'Open the owner tools menu'})}),(0,X.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,X.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:te,headerExtra:(0,X.jsx)(J,{open:re,onPress:()=>ie(!0)}),subHeader:(0,X.jsx)(Q,{name:$e,access:ze,day:He,at:Me})}),oe&&Pe?(0,X.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,X.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,X.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,X.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:oe.page?'Back to all settings':`Close ${oe.btn.label}, back to the floor plan`,onPress:()=>oe.page?ne({...oe,page:null}):ne(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,X.jsx)(f.T,{weight:"semibold",center:!0,children:oe.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,X.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,X.jsx)(l.default,{ref:je,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,X.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:We})}),(0,X.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,_.deskCopy)(Le?.sub??oe.btn.hint)})]}),(0,X.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,X.jsx)(J,{testID:"desk-menu-button-page",open:re,onPress:()=>ie(!0)})})]}),Ie.length>1&&!oe.page?(0,X.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Ie.map(e=>{const t=e.id===oe.tab;return(0,X.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>ne({btn:oe.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?Z:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,X.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,X.jsx)(i.default,{ref:we,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(!oe||!Pe)return null;if(oe.page)return Fe(oe.page);switch(oe.tab){case'@desk-bookings':return(0,X.jsx)(K.DesktopBookings,{filterRef:ye});case'@desk-hours':return(0,X.jsx)(K.DesktopHours,{go:Oe,filterRef:ye});case'@desk-takings':return Ce?(0,X.jsx)(K.DesktopTakings,{go:Oe}):(0,X.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,X.jsx)(K.DesktopSettings,{open:e=>ne(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,X.jsx)(G.DeskPermissions,{});case'@desk-leavers':return(0,X.jsx)(G.DeskLeavers,{});case'@desk-temps':return Ae((0,X.jsx)(G.DeskTemps,{}));case'@desk-bookinghistory':return Ae((0,X.jsx)(G.DeskCoversHistory,{}));case'@bookings':return(0,X.jsx)(H.Bookings,{go:Oe});case'@chat':return(0,X.jsx)(M.Chat,{go:Oe});case'@noshows':return Ae((0,X.jsx)(W.NoShows,{go:Oe}));case'@orders':return(0,X.jsx)($.Orders,{});case'@forecast':return(0,X.jsx)(E.Forecasts,{go:Oe});default:return Fe(oe.tab)}})()})]}):null]}),(0,X.jsx)(ee,{visible:re,buttons:De,current:oe?.btn.id,W:te,H:se,onClose:()=>ie(!1),onPick:e=>Se(e),onFind:()=>{ie(!1),ae(!0)},onKeys:()=>{ie(!1),ge(!0)},onInstall:()=>{ie(!1),pe(!0)},onSignOut:()=>{ie(!1),fe(!0)}}),le?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ae(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,X.jsx)(p.TextInput,{ref:ke,value:de,onChangeText:ce,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,X.jsx)(l.default,{'aria-live':'polite',children:(0,X.jsxs)(f.Muted,{center:!0,children:[Be.length," pages"]})}),Be.slice(0,60).map(e=>(0,X.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,X.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,X.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ue?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ge(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,_.SHORTCUTS)((0,F.isMac)()).map(([e,t])=>(0,X.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,X.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,X.jsx)(f.T,{center:!0,children:t})]},e)),(0,X.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,be?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>fe(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,X.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,X.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,X.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>fe(!1),testID:"desk-signout-cancel"}),(0,X.jsx)(f.Button,{label:me?'Signing out\u2026':'Sign out',disabled:me,onPress:async()=>{xe(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,he?(0,X.jsx)(f.Sheet,{visible:!0,onClose:()=>pe(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,X.jsx)(U.DesktopInstallPage,{})}):null,(0,X.jsx)(k.SeatAllergenReminder,{rid:e}),(0,X.jsx)(x.PrintHost,{rid:e}),(0,X.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Oe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,X.jsx)(z.OnboardingHost,{go:Oe}),(0,X.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]);r(d[37]);var F=r(d[38]),_=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]);const q=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Y=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},Z='rgba(201,162,74,0.14)';function J({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,X.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,X.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,X.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,X.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function Q({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,X.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,X.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,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function ee({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,V.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(()=>Y(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,F.isMac)();return(0,X.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,X.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,X.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,X.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,X.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,X.jsx)(l.default,{style:{width:56}}),(0,X.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,X.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,X.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,X.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,V.deskShortcut)(t,B);return(0,X.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,X.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:Z,alignItems:'center',justifyContent:'center'},children:(0,X.jsx)(G.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,X.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,X.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,X.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1556,[17,266,347,219,385,278,85,409,19,780,812,779,777,1229,1392,1087,1479,1086,1084,1231,1244,891,876,1032,1487,880,899,804,1339,1557,1057,1417,1160,1481,1483,1472,1456,1485,1553,1555,1563,1564,1565,1568,1571,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))}},1557,[17,266,347,219,385,278,85,409,780,779,1339,1456,1485,1417,1160,1483,1481,1057,1026,777,858,876,863,899,880,804,1558,1559,1560,1561,1562,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1558,[]); -__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])},1559,[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])},1560,[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])},1561,[17,385,1162,1163,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},1562,[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,b=Math.round(1.4*h),k=Math.max(48,Math.min(72,c-2*b-14,l-34));return{panelW:n,colW:l,per:c,circle:k,label:h,lineH:b,icon:Math.round(.44*k),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}],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'},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','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}`},1563,[1558]); -__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)},1564,[]); -__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,f.useOwner)(e=>e.staff),x=(0,f.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)),T=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=T.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,f.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,D.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,m.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,D.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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,D.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,D.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,f]=(0,t.useState)('next7'),[m,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[T,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,D.bookingColumns)(T),[T]),E=(0,t.useMemo)(()=>(0,D.sortRows)((0,D.filterRows)((0,D.bookingsBetween)(r,W,L,m),z,x),z.find(e=>e.key===$),M),[r,W,L,m,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:()=>f(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:m===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:T?'Hide phone numbers':'Show phone numbers',selected:T,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,D.csvName)('bookings',W,L),(0,D.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,D.ddmmyyyy)(W)}${L!==W?` to ${(0,D.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,D.ddmmyyyy)(W)} to ${(0,D.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,D.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${D.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,D.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",D.STATUS_WORD[G.status]??G.status]}),G.phone&&T?(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,f.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,m]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,T]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,f.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,D.ukTime)(e.in),outT:(0,D.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,D.sortRows)((0,D.filterRows)(O.filter(e=>'all'===p||e.status===p),D.HOURS_COLUMNS,y),D.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:m,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,D.csvName)('hours',R,M),(0,D.toCsv)(N,D.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,D.hm)((0,D.totalPaid)(N))} paid \xb7 ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`,cols:D.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(T(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,D.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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:T.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...T.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!T.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,T.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,T.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,T.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]),f=_r(_d[13]),m=_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]),T=_r(_d[23]),D=_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 f.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]}},1565,[17,385,85,409,812,777,1072,1032,1179,1122,1091,858,1008,876,1055,839,889,899,804,1417,1057,1456,1566,1555,1564,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}),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},1566,[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)}.`}},1567,[17,85,780,777,804,1566,1564,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}]},1568,[17,264,385,85,780,777,858,876,1569,915,1214,1463,804,1559,1057,1566,1570,1564,1567,1565,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)}))},1569,[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)},1570,[915]); -__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))})]})}},1571,[17,85,777,804,1572,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)},1572,[]); -__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:h,today:O,now:I,meId:N,me:X}=(0,A.useCtx)(3e4);(0,x.useTipsPosted)(e,O);const Z=(0,A.useSignedIn)();(0,m.useSoldOutLink)(!0,(Z?.name??X).replace(' (example)',''));const[q,J]=(0,s.useState)({kind:'tab',tab:'home'}),[Q,Y]=(0,s.useState)(''),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,A.ensureAttendance)(O,I),(0,D.ensureChat)(I)},[O]),globalThis.__ccNow=I.getTime();const te=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=V[t];return void J(e?{kind:'edit',id:e}:{kind:'page',id:t})}J('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:te}),()=>C.useVoiceNav.setState({go:null})),[te]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=te,globalThis.__deskGo=e=>J(e))},[te]),(0,v.useAlertWatcher)(e,{nag:'staff'!==h}),(0,w.useScheduledNotices)({rid:e,staffId:Z?.id??'',name:X,onOpen:e=>'bookings'===e?te('bookings'):'chat'===e?te('chat'):te('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==h&&!!Z});const ae=(0,s.useMemo)(()=>[...$,...F].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 ee.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=ae[Number(e.key)-1];return void(t&&(e.preventDefault(),J(t)))}if('z'===t&&!U(e.target)){const t=(0,z.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!U(e.target)){const t=(0,z.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae]);const se=B.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(h))&&!V[e.id]),ne=(0,s.useMemo)(()=>{const e=Q.trim().toLowerCase(),t={};return se.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[se,Q]),oe=$.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(h)),re=p.CAN.forecasts(h)?F:F.filter(e=>'rota'===e.s.id),ie='page'===q.kind?(0,B.pageFor)(q.id):void 0,le='tab'===q.kind?$.find(e=>K(e.s,q))?.label:'edit'===q.kind?F.find(e=>K(e.s,q))?.label:ie?.title,de='tab'===q.kind?$.find(e=>K(e.s,q))?.tip:'page'===q.kind?`${ie?.sub??''}. Press ${(0,_.CMD)()}K to jump to any page.`:'',ue=({label:e,s:t,n:a})=>{const s=K(t,q);return(0,W.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>J(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,W.jsx)(f.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,W.jsxs)(f.T,{size:11,colour:S.colours.muted,children:[(0,_.CMD)(),a]}):null]})},ce=({t:e})=>(0,W.jsx)(f.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),be='owner'===h?'OWNER':'manager'===h?'MANAGER':'STAFF';return(0,W.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,W.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,W.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(f.Row,{gap:10,children:[(0,W.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(u.VenueName,{name:c.name}),(0,W.jsx)(f.Row,{gap:6,children:(0,W.jsx)(l.AppBadge,{label:be})})]})]}),(0,W.jsx)(u.PoweredBy,{}),(0,W.jsx)(a.TextInput,{ref:ee,testID:"side-filter",value:Q,onChangeText:Y,placeholder:`Find a page (${(0,_.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[f.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,W.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Q?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{t:"Run the day"}),oe.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:t+1},e.label)),(0,W.jsx)(ce,{t:"Drag-and-drop editors"}),re.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:oe.length+t+1},e.label))]}),Object.entries(ne).map(([e,t])=>(0,W.jsxs)(r.default,{children:[(0,W.jsx)(ce,{t:e}),t.map(e=>(0,W.jsx)(ue,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,W.jsxs)(r.default,{style:{flex:1},children:[(0,W.jsx)(r.default,{testID:"desk-title",children:(0,W.jsx)(f.T,{size:24,weight:"bold",children:le??''})}),(0,W.jsxs)(f.Muted,{size:12,children:[Z?`Signed in as ${Z.name} \xb7 ${p.ROLE_LABEL[h]}`:`Preview \xb7 ${p.ROLE_LABEL[h]}`," \xb7 ",c.name]})]})}),(0,W.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[de?(0,W.jsx)(H.Tip,{children:de}):null,'edit'===q.kind?(0,W.jsx)(G,{id:q.id,rid:e,me:X,role:'owner'===h?'owner':'manager',today:O,venue:c.name}):(0,W.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===q.kind&&'home'===q.tab?(0,W.jsx)(L.Dashboard,{go:te}):null,'tab'===q.kind&&'orders'===q.tab?(0,W.jsx)(P.Orders,{}):null,'tab'===q.kind&&'bookings'===q.tab?(0,W.jsx)(E.Bookings,{}):null,'tab'===q.kind&&'forecast'===q.tab?(0,W.jsx)(R.Forecasts,{go:te}):null,'tab'===q.kind&&'chat'===q.tab?(0,W.jsx)(D.Chat,{go:te}):null,ie?(0,W.jsx)(ie.C,{go:te}):'page'===q.kind?(0,W.jsx)(f.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,W.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==h?(0,W.jsx)(g.PrintHost,{rid:e}):null,'staff'!==h?(0,W.jsx)(b.AlertHost,{variant:"managers",rid:e,me:X,onOpen:e=>te('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,W.jsx)(M.OnboardingHost,{go:te}),(0,W.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]),f=_r(d[12]),h=_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]);_r(d[33]);var O=_r(d[34]),_=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]);const $=[{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.'}],F=[{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:''}],V={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},K=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),U=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function G({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,h.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,W.jsx)(I.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,W.jsx)(N.RotaEditor,{today:o}):'brand'===e?(0,W.jsx)(O.BrandEditor,{rid:t}):(0,W.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,W.jsxs)(H.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,_.CMD)(),"Z undoes, then Save."]}),g?(0,W.jsx)(f.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,W.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,W.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{h.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)})]})}},1573,[813,812,17,385,278,85,19,1362,857,1365,1229,1392,777,998,876,891,1032,1479,1087,1086,1084,1487,1231,880,804,1417,1160,1057,1430,1481,1472,1483,1456,1485,1574,1553,1576,1578,1580,1577,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])},1574,[17,278,85,1500,857,777,876,814,1457,804,1575,1576,1577,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)})},1575,[]); -__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},1576,[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})},1577,[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."})]})]})}},1578,[812,17,85,777,860,816,891,893,894,845,867,1152,804,1575,1576,1577,1579,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])},1579,[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)}`},1580,[17,85,777,876,1060,804,1575,1576,1577,1051,1579,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]})}},1581,[13,17,856,1582,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)','')}})}},1582,[1457,1583,813,912,1072,1509,1208,1209,1028,1025,1026,1510,1544,1512,1152,891,978,1584,975,880,1031,1032,1493,914,1008,915,17,1154,1240,1244,1202,356,385,278,85,409,19,777,857,876,804,1160,1417,1066,1084,1086,1081,1027,1010,1057,1503,1498,1525,1585,1425,920,219,1245,1181,1187,1455,1201,1198,1480,1184,878,1211,1212,884,776,899,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']]},1583,[17,85,777,1057,899,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}},1584,[219,976]); -__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)','')},1585,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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]})}},1586,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1587,[1450,899,778,1411,1588,995,13,1615,479,17,368,319,219,24,85,805,857,1065,856,1617,19,858,998,876,804,1425,920,988,1618,1619,1028,1104,880,1008,914,1621,1381,8,1622,1623,1624,1625]); -__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])},1588,[1589,1612,1614]); -__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)}}},1589,[198,1590,1593,1607,1608,1609,1610,1611]); -__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}},1590,[198,1591]); -__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}},1591,[1592]); -__d(function(g,r,i,a,m,e,d){},1592,[]); -__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)}},1593,[1594,198,1590,1607,1608]); -__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]}})})},1594,[1595,1596,1606]); -__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()}})}},1595,[1596,1600,1605]); -__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}}},1596,[198,355,1597,1601,1602,1603,1604,1600,1605]); -__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}},1597,[198,1598,322,263,1599,1600]); -__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])},1598,[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}}},1599,[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},1600,[]); -__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}},1601,[]); -__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}},1602,[]); -__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])},1603,[1601]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},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}),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},1605,[355,1599]); -__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])},1606,[17,1596]); -__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}},1607,[1594,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])},1608,[1594,1607]); -__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}},1609,[1590]); -__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])},1610,[198,1590,1593,1591]); -__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})({})},1611,[]); -__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]))},1612,[198,37,1613]); -__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')},1613,[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]}},1614,[17,1589]); -__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]}})})},1615,[1616]); -__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(){}},1616,[]); -__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]})}},1617,[17,24,85,409,777,857,920,899,880,805,804,1558,1560,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()})},1618,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1619,[813,779,17,974,385,85,856,899,976,804,777,1351,971,880,1620,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1620,[17,1458,385,85,899,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1621,[]); -__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"},1622,[]); -__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"},1623,[]); -__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"},1624,[]); -__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"},1625,[]); -__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]})}},1626,[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},1627,[1628]); -__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},1628,[8,1629,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}))}}},1629,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1630,[]); -__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})}}},1631,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1278,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1279,[17,385,85,409,777,804,1190,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1280,[17,85,1281,777,858,920,1260,1263,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1281,[17,85,1282,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1282,[1283]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1283,[17,780,1284,1313,1314,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1284,[1285]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1285,[1286,1287,1310,1312]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1286,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1287,[1288,1289,1290,1291,1292,1293,1294,1295,1296,1299,1303,1300,1304]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1288,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1289,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1290,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1291,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1296,[1297]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1300,[1301,1302]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1301,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1302,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1305,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1306,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1308,[1300,1288]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1309,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1310,[1311]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1312,[1311]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1313,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1314,[17,780,1315,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1315,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1316,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1317,[822,13,17,85,1281,777,851,858,804,1280,1263,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1318,[822,13,17,85,1258,777,858,876,851,863,804,1259,1263,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1319,[822,13,17,777,858,876,863,804,1280,1263,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1320,[822,13,17,777,858,876,804,1280,1263,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1321,[13,17,777,863,1140,1322,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1322,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1323,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1324,[843,13,17,1249,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1325,[13,17,85,1254,777,845,862,858,804,1279,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1326,[13,17,1327,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1327,[17,85,777,1099,804,1328,1329,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1328,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1329,[928,971,1328]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1330,[843,13,17,85,1256,777,845,851,863,858,804,1331,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1331,[17,354,362,219,13,777,851,804,900,1332,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1332,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1333,[843,1263,13,17,85,777,845,851,863,858,864,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]})}},1334,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1335,[822,13,17,777,858,805,1263,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1336,[13,17,777,1337,1154,1263,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1337,[812,843,17,85,777,845,851,1154,1338,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1338,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1339,[13,17,856,1340,1412,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1340,[1053,779,805,806,1341,813,1342,1094,843,1140,1343,1344,1345,1091,1122,1346,1347,1352,1353,1210,1354,856,1359,1360,1361,1115,1113,920,1362,1153,891,1104,1363,17,1072,1185,1018,1087,1364,21,378,363,385,278,85,409,19,777,1241,1245,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1365,1108,1366,1372,1374,1378,1383,1377,1384,1387,1388,1117,1095,1096,862,1393,1230,1394,1240,1232,995,1399,1404,1405,1054,1052,1119,1407,1408,1409,1071,1172,1410,1171,1162,853,1355,1411,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1343,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1344,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1345,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1346,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1347,[17,378,385,409,85,1281,777,1172,779,998,1348,1349,1351,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1348,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1349,[17,378,385,278,395,85,409,779,777,804,1350,1351,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1350,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1351,[993,856,1350,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1352,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1353,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1354,[1168,17,219,385,85,777,1167,804,876,920,1355,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1355,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1356,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1356,[831,928,899,1357,880,1358]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1357,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1358,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1359,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1361,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1362,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1363,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1364,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1365,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1366,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1367,1369,1368,998,876,1108,1370,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1367,[813,843,17,1368,85,842,804,777,1109,1369,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1368,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1369,[1368,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1370,[17,368,278,85,842,982,1371,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1371,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1372,[17,219,385,85,804,777,1172,1373,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1373,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1374,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1375,841,863,1096,1376,804,777,1377,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1375,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1376,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1377,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1378,[805,813,17,266,319,219,385,85,409,804,857,1379,777,999,916,1352,1381,880,1382,1383,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1379,[17,219,85,1380,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1380,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1381,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1383,[17,831,928,899,1382]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1384,[843,841,998,1385,1386]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1385,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1386,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1387,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1388,[1389,843,1095,998,17,85,777,1098,858,1116,1384,1096,863,1093,1117,1118,1119,804,1344,1391,1392,1115,1361,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1389,[17,362,385,85,858,920,876,996,1390,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1390,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1393,[1172,1389,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1377,858,998,845,1089,1076,1322,804,1344,1391,1392,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1394,[812,17,219,385,85,777,858,998,1395,804,1396,1398,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1395,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1396,[831,858,998,1395,1397,1398]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1397,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1398,[219,1397]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1399,[843,17,1189,1172,385,85,995,998,862,863,804,777,1400,1403,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1400,[1401,854,843,17,264,378,385,278,85,858,995,998,1402,863,804,1026,777,1403,1356,899,1344,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1401,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1402,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1403,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1405,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1406,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1407,[843,1385]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1408,[17,385,85,777,1407,804,1364,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1409,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1410,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1411,[17,1005,876,926,816,1006,916,1356,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1412,[805,813,857,17,219,385,85,409,899,804,777,1352,1413,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1413,[]); +__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]})}},1414,[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]})}},1415,[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,{})}},1416,[13,17,1417,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])},1417,[17,856,1418,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}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return H.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]),Y=_r(d[45]);_r(d[46]);var 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,Q.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,Q.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,K.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,K.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,J.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)(()=>{G.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,M.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)(z.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)(z.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'!==H.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'===H.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'===H.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.jsx)(D.AssistantRequestsButton,{go:Be,testID:"assistant-requests-top"}),(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'===H.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)(F.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(Y.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(U.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(Q.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(K.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.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)(W.OnboardingHost,{go:Be}),(0,le.jsx)(V.CoachHost,{})]})}},1418,[805,813,899,1193,1228,1210,1028,1025,891,1026,880,1032,1087,17,356,378,385,278,409,85,19,777,857,858,876,804,1419,1184,1057,884,1427,920,219,1432,1472,839,856,1474,1481,1482,1483,1190,1246,1484,1458,1485,1487,1456,1161,1230,1394,1232,1245,1489,1084,1086,1555,1556,1575,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1419,[805,1420,1095,1270,1421,812,822,1117,1118,1091,1122,1422,1114,1119,1407,1408,1057,1344,996,1120,1089,841,1386,1125,1424,1241,1425,1399,1078,1055,1090,17,85,777,1364,858,845,851,863,1322,804,1184,1098,1115,998,1361,1062,1162,1426,1232,899,1186,1404,862,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1420,[]); +__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])},1421,[806,17,85,777,899,1274,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1422,[17,385,85,1423,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1423,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1424,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1187,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1425,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1426,[17,85,864,858,848,804,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1427,[1428,17,219,24,85,856,1429,920,804,1431,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1428,[]); +__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])},1429,[17,278,85,777,857,804,1430,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(' ')},1430,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1431,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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:n=!1}){const{rid:a,r:x,now:H,role:ae,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(a),ce=(0,p.useBookings)(a),ue=(0,p.useWaitlist)(a),ge=(0,p.useEvents)(a),xe=(0,p.useRatings)(a),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,S.useRealHistory)(a,H),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,H,pe??void 0),[x,ce,de,ge,pe,H.getTime()/6e4|0]),ke=(0,M.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),Ie=de.filter(B.LIVE),ve=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=Ie.filter(e=>(0,U.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,U.bookingNeedsAction)(e,Ie)),Ae=Ie.flatMap(e=>(0,I.readinessFor)(e,x,H).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Se=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Me=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,v.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(H),He=ke?(0,L.revenueHistory)(x,H,7).filter(e=>e.date.getDay()===H.getDay()).pop():void 0,Fe=ke?{today:186e3+Ne,last:He?{date:(0,v.ymd)(He.date),pence:He.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,a,Pe,Ne),We=j.CAN.takings(ae)&&(!(0,W.isLive)()||(0,W.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,H,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(H),(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)(ae,qe,{inStaffApp:Ye,live:(0,W.isLive)()}),Ve=(0,F.homeSetupNagsHidden)(a),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,st]=(0,l.useState)(!1),ot=ie.replace(' (example)',''),lt=j.CAN.manage(ae)?(0,ne.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,ne.jsxs)(b.default,{style:{gap:12},children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(i.DayView,{rid:a,day:Ue,today:re,app:"owner"})]}):(0,ne.jsxs)(b.default,{style:{gap:12},testID:n?'owner-home':'managers-home',children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(K.WhoBar,{}),qe&&'owner'!==qe.role?(0,ne.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ne.jsx)(X.MyTasksToday,{rid:a,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ae?(0,ne.jsx)(Z.TodaysTipsCard,{rid:a,today:re}):null,'staff'!==ae?(0,ne.jsx)(Z.TipsPotCard,{rid:a,today:re}):null,j.CAN.manage(ae)?(0,ne.jsx)(b.default,{testID:"home-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.jsx)(f.Button,{testID:"home-insights-toggle",kind:tt?'secondary':'primary',label:tt?'Hide insights':'Insights',accessibilityLabel:tt?'Hide insights':'Insights: business insights, stats and suggestions. Closed until you tap.',onPress:()=>st(e=>!e),style:{minHeight:56,width:'100%'}})}):null,j.CAN.manage(ae)&&tt?(0,ne.jsxs)(b.default,{testID:"home-insights-panel",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,ne.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.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%'}})}),(0,ne.jsx)(le.SuperProInsights,{go:e}),(0,ne.jsxs)(b.default,{testID:"home-insights-feed",style:{gap:12,width:'100%'},children:[(0,ne.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,ne.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ne.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,ne.jsxs)(f.T,{weight:"semibold",center:!0,children:[t.icon," ",t.title]}),(0,ne.jsx)(f.Muted,{center:!0,children:t.body}),t.action?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'center'}}):null]})},t.id)),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights'),style:{alignSelf:'center'}})]})]}):null,(0,ne.jsx)(ye,{split:De}),(0,ne.jsx)(te.BlocksBanner,{rid:a,now:H,by:ie}),(0,ne.jsx)(y.KitchenSignoffs,{rid:a,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(o.SeasonsTodo,{go:e}):null,(0,ne.jsx)(r.LastFoodBanner,{rid:a,now:H}),(0,ne.jsx)(d.NextTableFreeCard,{rid:a,now:H}),j.CAN.manage(ae)?(0,ne.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,ne.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,ne.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ne.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ae)?(0,ne.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:a,r:x,now:H,by:ie}):null]}),ze.elements,j.CAN.manage(ae)?(0,ne.jsx)(Y.PaydaysCard,{go:e}):null,(0,ne.jsx)(E.FadeIn,{children:(0,ne.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ne.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,ne.jsx)(S.ExampleBadge,{}):je.enough?(0,ne.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ne.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ne.jsx)(E.Gauge,{pct:Le?Se.pct:0,label:Le?Se.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,ne.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ne.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,je.enough?(0,ne.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,ne.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ne.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ne.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||Ie.length?(0,ne.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Live orders",value:"",accent:Ie.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${Ie.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${Ie.filter(e=>'table'===e.type).length} table`:`${Ie.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ne.jsx)(E.CountUp,{value:Ie.length})})}):null,ve.length>0?(0,ne.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ne.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,ne.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(z.TakingsTodayCard,{t:Fe,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ne.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ne.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,ne.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,ne.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ne.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,v.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ne.jsx)(f.T,{size:14,children:t.detail}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ge.days.length||Ge.requests)?(0,ne.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,ne.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ae)?(0,ne.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ne.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ne.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ne.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,ne.jsxs)(f.Row,{gap:4,children:[(0,ne.jsx)(G.Mark,{p:"facebook"}),(0,ne.jsx)(G.Mark,{p:"instagram"}),(0,ne.jsx)(G.Mark,{p:"tiktok"}),(0,ne.jsx)(G.Mark,{p:"youtube"})]}),(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ne.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ne.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ne.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ne.jsx)(B.SectionHead,{title:e})}),(0,ne.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ne.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ne.jsxs)(f.Card,{children:[0===Oe.length?(0,ne.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,ne.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ne.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,v.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ne.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ne.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),Ke?(0,ne.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,ne.jsx)(E.FadeIn,{children:(0,ne.jsx)(he,{rid:a,today:re})}):null,'owner'!==ae||V.IS_CAR?null:(0,ne.jsx)(f.Button,{testID:"home-customer-support",label:"Customer support",accessibilityLabel:"Customer support, send a message or a picture to CoverCharge",onPress:()=>e('more','support'),style:{minHeight:56,width:'100%'}}),(0,ne.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:a,by:ot,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]),n=_r(_d[4]),a=e(n),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]),I=_r(_d[21]),v=_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]),S=_r(_d[29]),M=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),H=_r(_d[33]),F=_r(_d[34]),W=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),_=_r(_d[41]),U=_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]),ne=_r(_d[56]);const ae=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 a=3/Math.sqrt(n);o[e]=a*t*s[e],o[e+1]=a*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)&&n.push(e);for(;n.length&&o(e)-o(n[n.length-1])<36;)n.pop();return[...n,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&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/I*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:v(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],S=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?.(M(s)))},M=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,F=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,W=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)} ${F}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${W?` ${W.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,n)=>(0,ne.jsx)(m.default,{testID:n,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,ne.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ne.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ne.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ne.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ne.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,ne.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,ne.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ne.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:F}),(0,ne.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),W?(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:W}):null]}):(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ne.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ne.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ne.jsxs)(a.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ne.jsx)(n.Defs,{children:(0,ne.jsxs)(n.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ne.jsx)(n.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ne.jsx)(n.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ne.jsx)(n.Line,{x1:ae,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.Circle,{cx:v(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ne.jsx)(n.Line,{x1:v(L.day),y1:10,x2:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:M(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:v(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ne.jsx)(b.default,{testID:"mt-axis",style:{height:H.AXIS_BAND+6,minHeight:H.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ne.jsx)(f.T,{size:H.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:v(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ne.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ne.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>S(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ne.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:M(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ne.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ne.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,ne.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>S(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,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ne.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: card + cash \u2212 card tips. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ne.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ne.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,ne.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ne.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ne.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,ne.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ne.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1432,[843,1140,1433,17,780,1185,1074,1075,1425,1344,861,1078,264,385,85,777,858,876,1211,1193,845,1160,863,1055,866,804,1184,1057,1139,1145,1146,1008,839,1150,886,899,915,1443,1444,1149,1445,1162,853,1448,1188,1209,856,1207,1031,1032,1066,1098,1399,1153,1343,1466,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."})]})}},1433,[1053,1033,805,1420,812,1434,1435,1437,1438,1439,1203,1031,1032,1008,1014,17,385,85,777,841,1440,816,862,1055,861,804,1057,858,1187,926,927,876,1441,1394,998,1442,1005,1142,892,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)},1434,[812,17,85,777,1140,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)},1435,[843,17,219,85,777,858,998,1154,1263,899,1338,1436,8]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1436,[843,1285]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1437,[17,85,777,998,1348,804,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1438,[17,85,777,998,863,1402,805,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1439,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1440,[17,1033,85,804,777,1260,1263,8]); +__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1441,[17,85,777,998,1368,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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),S=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>C(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>C(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>f(null),onSave:t=>{y.update(e.id,t),f(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",S(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>f(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:I,onCancel:()=>f(null),onSave:t=>{y.add(e,t),f(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>f('new')}),(0,k.jsxs)(r.Sheet,{visible:!!p,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:p?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{p&&y.remove(p.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{f.useOrderLists.getState().ensure(e)},[e]);const s=(0,f.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,f.orderSettingsOf)(e);(0,f.useOrderLists)(t=>t.settings[e]);const l=f.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),f=(0,s.privateClockVenue)(e),[p,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[S,v]=(0,n.useState)(!1),[C,I]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(f)return;v(!0),I('');const t=await(0,b.getFix)();if(v(!1),'object'!=typeof t)return void I('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),I(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:f?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),f?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),f?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:S?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:S,onPress:()=>{B()}}),C?(0,k.jsx)(r.Muted,{size:13,children:C}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:p,onChangeText:j,onBlur:()=>R(p,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(p,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),f?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"The full CookSafe log is in the food safety menu: CookSafe log."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_r(_d[5])),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},S=[1,2,3,4,5,6,0],v=['on_shift','everyone','managers','head_chef','kitchen','foh'],C=e=>e.replace(' (example)',''),I={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:C(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[v.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:C(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,f]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),p=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{f(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:S.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),p?(0,k.jsx)(r.Muted,{size:13,children:p}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!p,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>f.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1442,[812,912,17,362,385,85,777,804,1005,1006,876,1010,1011,1012,913,1068,899,1029,916,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1443,[]); +__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7])},1444,[17,385,85,777,804,1149,1443,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1445,[886,779,816,813,822,862,1039,1446,17,909,319,362,219,385,85,777,858,876,863,804,1184,1057,1221,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1446,[482,1447]); +__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}});var t={}},1447,[]); +__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.ProgressBar=L,_e.useSetupDone=F,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,T.useCtx)(6e4),n=F(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=k.SETUP_STEPS.findIndex(e=>e.id===a),s=k.SETUP_STEPS[e+1]?.id??null;return(0,R.jsx)(A,{id:a,wizard:!0,onBack:()=>l(e>0?k.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=k.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,R.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{gap:12,children:[(0,R.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsxs)(m.T,{size:20,weight:"bold",colour:C.colours.gold,children:["Set up ",t.name]}),(0,R.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,R.jsx)(L,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,R.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,R.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:C.colours.border,backgroundColor:C.colours.surface,overflow:'hidden'},children:k.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,R.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:C.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,R.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?C.colours.gold:'transparent',borderWidth:1.5,borderColor:t?C.colours.gold:C.colours.border},children:(0,R.jsx)(m.T,{weight:"bold",colour:t?C.colours.onGold:C.colours.muted,children:t?'\u2713':s+1})}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"medium",children:e.title}),(0,R.jsx)(m.Muted,{children:e.sub}),o.length?(0,R.jsxs)(m.T,{size:13,colour:C.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,R.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=A,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return V}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=F(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,R.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",colour:C.colours.gold,children:"Finish setting up"}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]}),(0,R.jsx)(L,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,R.jsxs)(m.Muted,{size:13,children:["Next: ",k.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]),M=_r(_d[29]),R=_r(_d[30]);const I=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=[1,2,3,4,5,6,0],B=/^([01]\d|2[0-3]):[0-5]\d$/,D=e=>{const s=(0,M.parseMoneyInput)(e);return null!=s&&s>0?Math.round(100*s):null},O=e=>k.SETUP_STEPS.findIndex(s=>s.id===e)+1;function L({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,R.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,R.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:C.colours.gold,borderRadius:5}})}),(0,R.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function F(e){const s=(0,k.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=k.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:k.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function A({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,T.useCtx)(6e4),l=F(a),r=l.prog,d=(0,i.useLiveVenue)(),u=k.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=N[e];return(0,R.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsxs)(m.T,{size:12,weight:"semibold",colour:C.colours.gold,children:["STEP ",O(e)," OF ",k.SETUP_STEPS.length]}),s&&o?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,R.jsx)(m.T,{size:13,colour:C.colours.muted,children:"All steps"})}):null]}),(0,R.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,R.jsx)(L,{done:r.done,total:r.total})]}),(0,R.jsx)(b,{rid:a,done:(t="Saved.")=>{k.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,R.jsx)(m.Banner,{kind:"success",title:p}):null,(0,R.jsx)(G,{rid:a,id:e,title:u.title,onDone:x}),s?(0,R.jsxs)(m.Row,{gap:10,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,R.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const U=({wizard:e,onPress:s,disabled:t,label:n})=>(0,R.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const _=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function W({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,T.useHourly)(),d=(0,k.useSiteSetup)(e),u=(0,k.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,f]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,S.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,k.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),f(null)},z=!!p?.id&&(E=p.id,w.ROSTER.some(e=>e.id===E));var E;const M=p?D(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=M||z&&!p.wage);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,R.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,R.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?C.colours.gold:C.colours.border,backgroundColor:s?'#1d1a14':C.colours.surface}),children:[(0,R.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"semibold",children:e.name}),(0,R.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,k.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,R.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,k.accessOf)(e.level,e.role)})]},e.id))}),y?(0,R.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:C.colours.gold},children:(0,R.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,R.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,R.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,R.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,R.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,R.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Access level"}),(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:k.ACCESS_LEVELS.map(e=>(0,R.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,R.jsxs)(m.Muted,{size:13,children:["Uses the ",k.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Pay"}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,R.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,R.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,R.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,R.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,S.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,R.jsx)(m.Field,{money:!0,label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=M&&M<1271?(0,R.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,R.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,R.jsxs)(m.Row,{gap:8,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,R.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),k.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:k.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=M&&s.setRate(t,M);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),k.useSetup.getState().patch(e,{staffGrade:o}),k.useSetup.getState().setLook(t,p.look),f(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,R.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,R.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(_(d.grades[0]?.id??'')),f(null)}}),(0,R.jsx)(U,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const N={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,k.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,R.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,R.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,R.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,R.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':(0,y.builtInLogoCopy)(e)," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,R.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,R.jsx)(z.OrderAtTableCard,{rid:e,compact:!0}),u?(0,R.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,R.jsx)(U,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,T.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=$.filter(e=>{const s=n[e];return s&&(!B.test(s[0])||!B.test(s[1]))});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),I.map((e,s)=>{const t=$[s],l=n[t];return(0,R.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:C.colours.border,paddingTop:s?6:0},children:[(0,R.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,R.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"to"}),(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,R.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,R.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries($.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,R.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,R.jsx)(U,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,f.usePlan)(e),o=(0,f.planCounts)(n);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P.TablePlan,{startStep:"areas"}),(0,R.jsx)(U,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,R.jsx)(W,{...e,payList:!0})]})},staff:W,permissions:function({done:e,wizard:s}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E.PermissionsScreen,{}),(0,R.jsx)(U,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,k.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,R.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,R.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,R.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,R.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,R.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,R.jsx)(U,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),a=(0,k.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,v.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,R.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,R.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:C.colours.border,padding:10},children:(0,R.jsx)(m.T,{size:14,colour:C.colours.goldLight,children:i})}),(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,v.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,R.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,R.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,R.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,R.jsx)(U,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),k.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,T.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,R.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,R.jsx)(U,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},V=e=>function(){return(0,R.jsx)(A,{id:e})};function G({rid:e,id:s,title:t,onDone:n}){const o=F(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,R.jsxs)(g.default,{style:{gap:4},children:[(0,R.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),k.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,R.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,R.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1448,[888,887,813,812,1039,1449,1450,1451,1452,1454,17,385,85,857,884,777,858,876,1455,998,886,878,851,804,1057,1456,1459,1463,1464,840,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1449,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1450,[17,899]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1451,[17,831,899]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1452,[880,812,17,219,366,85,777,1453,899,804,1188,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1453,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1454,[17,385,777,899,804,1452,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.builtInLogoCopy=function(o){return'anchorage'===o?'The Anchorage logo in black and gold.':'Placeholder initials.'}},1455,[]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1456,[812,891,1140,899,780,1230,1232,17,264,362,219,385,85,409,864,777,858,1241,876,851,863,804,1184,1057,853,1055,1445,1161,1457,1458,1139,1146,1145,1008,839,1142,1149,1221,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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1457,[812,17,1228,1026,854,362,385,85,777,876,851,863,804,1184,1057,1221,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1458,[978,17,385,85,777,876,804,1057,1161,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1459,[812,17,1018,378,85,1108,1109,1366,1399,777,995,998,863,804,1057,999,1460,1461,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1460,[812,17,385,85,777,804,998,805,999,856,899,8]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1461,[17,85,777,998,1462,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1462,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1463,[805,1420,17,85,777,858,876,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.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 ')}},1464,[17,264,385,85,777,804,915,1465,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.'},1465,[928,899,876,856,915]); +__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 P}}),_e.useInsightsAccess=S,_e.SuperProInsights=_,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,D.jsx)(o.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,D.jsx)(_,{go:e})}):(0,D.jsx)(E,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.sales)return(0,D.jsx)(E,{});const r=i.sales;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Last 7 days"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=r.last7?(0,x.moneyGbp)(r.last7):'\u2014'}),r.missing7?(0,D.jsx)(l.Muted,{center:!0,children:`From ${r.days7} of ${r.days7+r.missing7} cash ups. ${r.missing7} ha${1===r.missing7?'s':'ve'} no card or cash total yet, so ${1===r.missing7?'it is':'they are'} not in the total.`}):null,(0,D.jsx)(l.Muted,{center:!0,children:null!=r.prev7?`The 7 days before: ${(0,x.moneyGbp)(r.prev7)}${null!=r.changePct?` (${r.changePct>=0?'up':'down'} ${Math.abs(r.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,D.jsx)(l.Muted,{center:!0,children:null!=r.sph7?`Spend per head ${(0,x.moneyGbp)(r.sph7)}, on the ${r.sphDays7} day${1===r.sphDays7?'':'s'} with takings and Covers`:'Spend per head shows once days have takings and Covers'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Takings by week"}),(0,D.jsx)(O,{values:r.weeks.map(e=>e.gross),w:300,h:70}),r.weeks.slice().reverse().map(e=>(0,D.jsx)(W,{a:`${(0,w.ukDate)(e.from)} \u2013 ${(0,w.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up${e.missing?`, ${e.missing} with no card or cash total`:''}`:e.missing?`Not enough data: ${e.missing} cash up${1===e.missing?'':'s'} with no card or cash total`:'No signed-off cash ups'},e.to)),(0,D.jsx)(l.Muted,{center:!0,children:"Takings are card + cash \u2212 card tips from signed-off cash ups (Gross only for a prepaid function), as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,D.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.stock)return(0,D.jsx)(E,{});const r=i.stock;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Low or out now"}),(0,D.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."}),r.low.length?r.low.map(e=>(0,D.jsx)(W,{testID:`low-${e.key}`,tone:e.out?k.colours.red:k.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,D.jsx)(l.Muted,{center:!0,children:r.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:`Price rises in the last ${w.RISE_DAYS} days`}),r.rises.length?r.rises.map(e=>(0,D.jsx)(W,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,$.gbp)(e.before)} \u2192 ${(0,$.gbp)(e.after)} a pack \xb7 ${(0,w.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,D.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,D.jsx)(l.Muted,{center:!0,children:r.lastCount?`Last full stock count ${(0,w.ukDate)(r.lastCount)}.`:'No full stock count yet.'})]}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.gp)return(0,D.jsx)(E,{});const r=i.gp;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,D.jsx)(A,{example:i.example}),i.example?(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:k.colours.gold,children:L(r.menu)}),null!=r.startMenu&&null!=r.menu?(0,D.jsx)(l.Muted,{center:!0,children:`${G(r.menu-r.startMenu)} points since ${(0,w.ukDate)(r.trend[0]?.week??'')}`}):null,(0,D.jsx)(O,{values:r.trend.map(e=>e.menu),w:300,h:80})]}):null!=r.menu?(0,D.jsx)(v.GpOverTime,{rid:s}):(0,D.jsx)(o.default,{testID:"insights-gp-not-enough",style:{width:'100%'},children:(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP"}),(0,D.jsx)(l.T,{weight:"semibold",center:!0,children:"Not enough data"}),(0,D.jsx)(l.Muted,{center:!0,children:`${r.fullyCosted} of ${r.costed} costed dishes have every recipe ingredient costed. Menu GP shows once ${w.MIN_FULLY_COSTED} or more are, so a part-costed dish cannot make GP look too high.`})]})}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),r.drops.length?r.drops.map(e=>(0,D.jsx)(W,{testID:`drop-${e.dishId}`,tone:k.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,w.ukDate)(e.date)}`},e.dishId)):(0,D.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Each dish over 3 months"}),r.dishes.length?r.dishes.map(e=>(0,D.jsx)(W,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const s=S(),n=C(),{list:i,source:r}=N(),[a,d]=(0,t.useState)('all');if(!s.clock)return(0,D.jsx)(E,{});const c='unsigned'===a?i.filter(e=>!1===e.signed):i,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,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,D.jsx)(A,{example:!!n}),(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${i.length})`,onPress:()=>d('all'),testID:"clock-filter-all"}),(0,D.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${i.filter(e=>!1===e.signed).length})`,onPress:()=>d('unsigned'),testID:"clock-filter-unsigned"})]}),(0,D.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:c.length?c.map(e=>(0,D.jsxs)(o.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${w.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,w.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:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?k.colours.amber:k.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,w.ukDate)(e.workDate)}`}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,children:`${w.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,D.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,D.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,D.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,D.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${w.CLOCK_DAYS} days.`})}),(0,D.jsx)(l.Muted,{center:!0,children:'server'===r?'From the server\u2019s timesheet audit.':'synced'===r?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=_r(_d[1]),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=e(i),l=_r(_d[5]),a=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),$=_r(_d[15]),x=_r(_d[16]),w=_r(_d[17]),b=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),D=_r(_d[23]);const P='SuperPro';function S(){const{role:e}=(0,j.useCtx)(6e4),s=(0,j.useSignedIn)(),t=(0,j.useInStaffApp)();return(0,w.insightsAccess)({viewRole:e,signed:s,live:(0,b.isLive)(),inStaffApp:t,perm:e=>(0,b.can)(e)})}function C(){return(0,y.useExamples)()&&!(0,b.isLive)()?I.INSIGHTS_SAMPLE:null}function N(){const e=C(),s=(0,h.useOwner)(e=>e.attendance),n=(0,h.useOwner)(e=>e.staff),[o,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(e||!(0,b.isLive)())return;let s=!0;return(0,b.readClockChanges)(w.CLOCK_DAYS).then(e=>{s&&e&&i((0,w.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,t.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const t=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:t(o),source:'server'};const i=(0,w.addDaysYmd)((new Date).toISOString().slice(0,10),-w.CLOCK_DAYS);return{list:t((0,w.clockChangesFromAttendance)(s,i)),source:'synced'}},[e,o,s,n])}function M(e){const s=C(),[n,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(s||!e||!(0,b.isLive)())return;let t=!0;return(0,b.readLoyaltyInsight)().then(e=>{t&&o(e?(0,w.loyaltyInsight)(e.raw,e.source):null)}),()=>{t=!1}},[s,e]),s?s.loyalty:e&&(0,b.isLive)()?n:null}function T(e,n){const o=C(),i=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,a.useBookings)(e),y=(0,a.useOrders)(e),$=(0,d.useReviews)(e=>e.reviews),x=(0,h.useOwner)(e=>e.attendance),b=(0,j.useHourly)(),k=(0,u.useGpCalcView)(),v=(0,a.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),D=(0,g.useShellStore)((0,f.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,t.useMemo)(()=>{if(o)return{example:!0,...o};const t=v.map(e=>({id:e.id,dish:e.dish,price:e.price,ingCount:Array.isArray(e.ingredients)?e.ingredients.length:void 0})),a=new Date,d=(0,w.salesInsight)(i,l,e,n,(0,s.coverOverridesFor)(e)),c=x.filter(e=>!e.voided&&'confirmed'===(0,h.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,j.paidMins)(e,a).paid,ratePence:b[e.staffId]??0})),u=x.filter(e=>!e.voided&&'awaiting'===(0,h.attStatus)(e)).map(e=>e.date);return{example:!1,sales:d,stock:(0,w.stockInsight)((I??[]).filter(e=>!e.group),D,(s,t)=>(0,p.fmtStockCount)(e,s,t),k.ingredients,Object.values(k.counts??{}),n),gp:(0,w.gpInsight)(k.ingredients,k.cardCosts??{},t,k.settings,Object.values(k.deliveries??{}),n),bookings:(0,w.bookingsInsight)(l,e,n),orders:(0,w.ordersInsight)(y,e,n),reviews:(0,w.reviewsInsight)($,e,n),labour:(0,w.labourInsight)(c,i,e,n,u),salesReport:(0,w.salesReportInsight)(r,e)}},[o,i,r,l,y,$,x,b,e,n,k,v,I,D])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,G=e=>`${e>0?'+':''}${e.toFixed(1)}`;function O({values:e,w:s=220,h:t=44,testID:n}){const l=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(l.length<2)return null;const a=Math.min(...l.map(e=>e.v)),d=Math.max(...l.map(e=>e.v))-a||1,c=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/d*(t-12),h=l[l.length-1];return(0,D.jsx)(o.default,{testID:n,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,D.jsxs)(r.default,{width:s,height:t,children:[(0,D.jsx)(i.Polyline,{points:l.map(e=>`${c(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:k.colours.gold,strokeWidth:2.5,fill:"none"}),(0,D.jsx)(i.Circle,{cx:c(h.i),cy:u(h.v),r:3.5,fill:k.colours.gold})]})})}function R({title:e,big:s,line:t,tone:o,onPress:i,testID:r,children:a,a11y:d,plan:c}){return(0,D.jsxs)(n.default,{testID:r,accessibilityRole:"button",accessibilityLabel:d,accessibilityHint:"Opens the detail",onPress:i,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??k.colours.gold,backgroundColor:e?k.colours.goldTint:k.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:e}),c?(0,D.jsx)(l.T,{size:11,weight:"semibold",colour:k.colours.goldLight,center:!0,children:c.toUpperCase()}):null,(0,D.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??k.colours.text,children:s}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.muted,children:t}),a,(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.goldLight,children:"Open \u203a"})]})}function A({example:e}){return(0,D.jsxs)(o.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.T,{size:20,weight:"bold",colour:k.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,D.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,D.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function B({title:e,sub:s,children:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.Badge,{kind:"gold",label:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]}),(0,D.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function _({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t),r=N(),l=M(n.loyalty);if(!n.any)return null;const a=(0,w.clockSummary)(r.list),d=(0,w.loyaltyLine)(l),c=s=>e('more',s),u=i.sales,h=i.stock,g=i.gp,p=i.bookings,f=i.orders,y=i.reviews,b=i.labour,v=i.salesReport,I=e=>w.INSIGHT_PLAN[e],C=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=n.sales||n.stock||n.gp||n.clock,E=n.bookings||n.noshows||n.orders||n.loyalty||n.reviews||n.labour||n.salesReports;return(0,D.jsxs)(o.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,D.jsx)(A,{example:i.example}),_?(0,D.jsxs)(B,{testID:"insights-group-superpro",title:P,sub:"Connected EPOS insights",children:[n.sales?(0,D.jsx)(R,{plan:I('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>c('insights-sales'),big:C(u.last7),line:null==u.last7?u.missing7?`Not enough data: ${u.missing7} cash up${1===u.missing7?'':'s'} in the last 7 days ha${1===u.missing7?'s':'ve'} no card or cash total`:'No signed-off cash ups in the last 7 days':`Last 7 days, card + cash \u2212 card tips from ${u.days7}${u.missing7?` of ${u.days7+u.missing7}`:''} cash-up day${u.days7+u.missing7===1?'':'s'}${u.missing7?` (${u.missing7} with no card or cash total)`:''}${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)}`:u.missing7?'Not enough data, the cash ups have no card or cash total':'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,D.jsx)(O,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,n.stock?(0,D.jsx)(R,{plan:I('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>c('insights-stock'),tone:h.low.length?k.colours.amber:void 0,big:h.low.length?`${h.low.length} low`:h.tracked?'None low':'\u2014',line:`${h.low.length?h.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):h.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${h.rises.length} price rise${1===h.rises.length?'':'s'} in ${w.RISE_DAYS} days`,a11y:`Stock. ${h.low.length} tracked items low or out. ${h.rises.length} price rises in ${w.RISE_DAYS} days`}):null,n.gp?(0,D.jsx)(R,{plan:I('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>c('insights-gp'),tone:g.drops.length?k.colours.amber:void 0,big:null==g.menu?'\u2014':L(g.menu),line:null==g.menu?`Not enough data: ${g.fullyCosted} of ${g.costed} costed dishes have every ingredient costed`:`Menu GP, ${g.fullyCosted} fully costed dishes${null!=g.startMenu?` \xb7 ${G(g.menu-g.startMenu)} pts in 3 months`:''} \xb7 ${g.drops.length} dish${1===g.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(g.menu)}. ${g.drops.length} dishes fell after a cost change`,children:(0,D.jsx)(O,{testID:"insight-gp-spark",values:g.trend.map(e=>e.menu)})}):null,n.clock?(0,D.jsx)(R,{plan:I('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>c('insights-clock'),tone:a.unsigned?k.colours.amber:void 0,big:String(a.total),line:`Edits in ${w.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 ${w.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,D.jsxs)(B,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[n.salesReports?(0,D.jsx)(R,{plan:I('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:C(v.gross),line:v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}${v.top.length?` \xb7 ${v.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}, ${C(v.gross)}`:'None yet')}):null,n.bookings?(0,D.jsx)(R,{plan:I('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,n.noshows?(0,D.jsx)(R,{plan:I('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?k.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}${n.sales?` (${(0,$.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,n.orders?(0,D.jsx)(R,{plan:I('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,$.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,n.reviews?(0,D.jsx)(R,{plan:I('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:y.low30?k.colours.amber:void 0,big:null!=y.avg30?`${y.avg30.toFixed(1)} \u2605`:'\u2014',line:`${y.count30} review${1===y.count30?'':'s'} in 30 days \xb7 ${y.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${y.avg30??'none'} stars from ${y.count30} reviews in 30 days`}):null,n.loyalty?(0,D.jsx)(R,{plan:I('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:d.big,line:d.line,a11y:`Loyalty. ${l?.members??'Not known'} members. ${l?.stampsMonth??'Not known'} stamps this month. ${l?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,n.labour?(0,D.jsx)(R,{plan:I('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=b.pct7&&b.pct7>35?k.colours.amber:void 0,big:null!=b.pct7?`${b.pct7}%`:'\u2014',line:null!=b.pct7?`Wages of takings on the ${b.days7} day${1===b.days7?'':'s'} with takings, last 7 days \xb7 ${C(b.labour7)} wages`:`Not enough data: no day in the last 7 has both signed-off hours and takings \xb7 ${b.paidHours7} signed-off hours`,a11y:`Wages and hours versus takings. ${b.pct7??'Not known'} percent over 7 days, ${b.paidHours7} hours`}):null]}):null]})}function E(){return(0,D.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function W({a:e,b:s,tone:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]})}},1466,[1467,17,385,85,780,777,858,1243,1008,905,876,895,897,864,1146,851,1468,1470,899,804,1057,1180,1471,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"coverOverridesFrom",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"coverOverridesFor",{enumerable:!0,get:function(){return c}});var o=r(_d[0]);const t={anchorage:{'2026-11-09':{covers:50,why:'BBC function, prepaid, 50 people (Gordon, 25 Nov 2026)'}}},n=(o,n)=>n?Object.fromEntries(Object.entries(t[o]??{}).map(([o,t])=>[o,t.covers])):{},c=t=>n(t,o.LIVE_VENUE_BUILD)},1467,[822]); +__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=l,_e.previousRange=function(e,n){const o=l(e,n);if('today'===n||'week'===n)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===n?1:0)-('today'===n?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===n?1:0)-('today'===n?1:0))};const[r,s]=o.from.split('-').map(Number),u=`${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=`${u.slice(0,7)}-${o.to.slice(8,10)}`;return{from:u,to:d<=c&&d>=u?d:c}},_e.changePct=function(t,e){return null==t||null==e||0===e?null:Math.round((t-e)/e*1e3)/10},_e.changeWords=function(t,e){if(null==t)return null;const n='today'===e?'yesterday':'week'===e?'last week':'last month';return 0===t?`No change vs ${n}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${n}`},_e.canSeeTakingsStats=function(t,e,n){return!('owner'!==t&&'manager'!==t||e&&!n)},_e.coversInRange=function(t,e){let s=0,l=0;for(const u of t){if(!u.date||!n(u.date,e))continue;if(!r(u.status))continue;const t=u.partySize||0;o(u)?s+=t:l+=t}const u=s+l;if(!u)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/u*100);return{total:u,walkIns:s,bookings:l,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,e,r){const l=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t)&&(s(t.status)||'noshow'===t.status));if(!l.length)return{rate:null,count:0,of:0,empty:!0};const u=l.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/l.length*1e3)/10,count:u,of:l.length,empty:!1}},_e.cancelRate=function(t,e,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const l=s.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(l/s.length*1e3)/10,count:l,of:s.length,empty:!1}},_e.takingsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{gross:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{gross:null,days:0,missing:u.length,missingDates:u}},_e.grossDays=u,_e.tipsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.combinedTips)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{tips:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{tips:null,days:0,missing:u.length,missingDates:u}},Object.defineProperty(_e,"completeTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"missingWords",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"takingsMissingWords",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return g}}),_e.tipsVsTakings=function(e,o,r){let s=0,l=0,u=0;for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals),d=(0,t.combinedTips)(c.vals);null==e||null==d||e<=0||(s+=d,l+=e,u+=1)}return u?{pct:g(Math.round(100*s)/100,Math.round(100*l)/100),days:u}:{pct:null,days:0}},_e.spendPerHeadInRange=function(t,n,o,r,s={}){const l=[...u(t,o,r).entries()].map(([t,r])=>({date:t,gross:r,covers:(0,e.coversOn)(n,o,t)+(s[t]??0)})),c=l.filter(t=>t.covers>0),d=l.length-c.length;if(!c.length)return{sph:null,covers:0,gross:null,days:0,noCovers:d};const f=Math.round(100*c.reduce((t,e)=>t+e.gross,0))/100,g=c.reduce((t,e)=>t+e.covers,0);return{sph:Math.round(f/g*100)/100,covers:g,gross:f,days:c.length,noCovers:d}},_e.labourCostInRange=h,_e.labourVsTakings=function(t,e,n,o,r){const s=u(n,o,r),l=s.size?Math.round(100*[...s.values()].reduce((t,e)=>t+e,0))/100:null,c=s.size?h(t,r,s):null;return{pct:m(c,l),labour:c,gross:l,days:s.size,awaiting:e.filter(t=>s.has(t)).length,labourAll:h(t,r)}},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return m}}),_e.repeatGuestPct=function(t,e,o){const r=new Set;for(const n of t){if(o&&n.restaurantId!==o)continue;if(!s(n.status)||n.date>=e.from)continue;const t=p(n);t&&r.add(t)}const l=new Set;let u=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!n(d.date,e))continue;const t=p(d);t&&!l.has(t)&&(l.add(t),u+=1,r.has(t)&&(c+=1))}return u?{rate:Math.round(c/u*1e3)/10,count:c,of:u,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.firstVisitDate=function(t,e){let n=null;for(const o of t)e&&o.restaurantId!==e||!s(o.status)||!o.date||(!n||o.date(null==t.status||'published'===t.status)&&n(t.createdAt.slice(0,10),e)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,e)=>t+e.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"NOT_SHOWN_YET",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return e.coversOn}});var t=_r(_d[0]),e=_r(_d[1]);const n=(t,e)=>t>=e.from&&t<=e.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function l(e,n){return'today'===n?{from:e,to:e}:'week'===n?{from:(0,t.weekStartOf)(e),to:e}:{from:`${e.slice(0,7)}-01`,to:e}}function u(e,o,r){const s=new Map;for(const l of e){if(l.rid!==o||!l.confirmedAt||!n(l.date,r))continue;const e=(0,t.tillTakingsOf)(l.vals);null!=e&&s.set(l.date,e)}return s}const c=(t,e)=>t.missing?null:e,d=(t,e,n)=>`Not enough data: ${t} cash up${1===t?' has':'s have'} no ${e} yet (${n.map(v).join(', ')})`,f=t=>`${t.length} cash up${1===t.length?' has':'s have'} no card or cash total yet (${t.map(v).join(', ')}), so ${1===t.length?'it is':'they are'} not in the total`,g=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function h(t,e,o){let r=0,s=!1;for(const l of t)!n(l.date,e)||l.ratePence<=0||l.paidMins<=0||o&&!o.has(l.date)||(r+=l.paidMins/60*l.ratePence,s=!0);return s?Math.round(r)/100:null}const m=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function p(t){const e=(t.phone||'').replace(/\s+/g,'').toLowerCase(),n=(t.email||'').trim().toLowerCase();return e.length>=7?`p:${e}`:n.includes('@')?`e:${n}`:null}const y='Not shown yet: GP and food cost %, table occupancy and top dishes. They need till sales, which CoverCharge does not have yet.',b={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.'},k=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,v=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,w=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1468,[839,1469]); +__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,u={}){const l=(0,r.weekStartOf)(o);return Array.from({length:d},(f,h)=>{const m=(0,r.addDaysYmd)(l,7*(h-d+1)),p=i(n,t,s,(0,r.addDaysYmd)(m,6),7,u).filter(r=>r.date<=o&&null!=r.gross),v=p.length?Math.round(100*p.reduce((r,n)=>r+n.gross,0))/100:null,y=p.reduce((r,n)=>r+n.covers,0);return{weekStart:m,gross:v,covers:y,days:p.length,sph:c(v,y)}})},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,l={}){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,h)=>{const m=(0,r.addDaysYmd)(o,h-i+1),p=f.get(m)?.vals??{},v=(0,r.tillTakingsOf)(p),y=d(t,s,m)+(l[m]??0),b=u(p.food),k=u(p.drink);return{date:m,gross:v,covers:y,sph:c(v,y),food:b,drink:k,foodPh:c(b,y),drinkPh:c(k,y)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.tillTakingsOf)(n.vals))},1469,[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=d,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return c}}),_e.salesInsight=function(e,t,r,o,s={}){const a={from:d(o,-6),to:o},i={from:d(o,-13),to:d(o,-7)},l=(0,n.takingsInRange)(e,r,a),c=(0,n.takingsInRange)(e,r,i),u=(0,n.spendPerHeadInRange)(e,t,r,a,s),f=u.sph,g=[];for(let t=7;t>=0;t--){const s=d(o,-7*t),a=d(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});g.push({from:a,to:s,gross:i.gross,days:i.days,missing:i.missing})}const p=null!=l.gross&&null!=c.gross&&c.gross>0&&!l.missing&&!c.missing?Math.round((l.gross-c.gross)/c.gross*1e3)/10:null;return{last7:l.gross,prev7:c.gross,changePct:p,days7:l.days,missing7:l.missing,sphDays7:u.days,sph7:f,weeks:g,empty:g.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=d(s,-30),c=[];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&&c.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})}c.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:c,lastCount:u?.date??null,empty:!a.length&&!c.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"MIN_FULLY_COSTED",{enumerable:!0,get:function(){return g}}),_e.fullyCostedIds=p,_e.gpInsight=function(n,r,o,s,a,i){const l=p(n,r,o,s),c=o.filter(e=>(r[e.id]?.lines?.length??0)>0).length;if(l.sizel.has(e.id)),f=(0,e.menuGp)(n,r,u,s),m=(0,e.gpHistory)(a,f,'3m',i),h=m.points.find(e=>null!=e.menu)?.menu??null,b=f.dishes.map(e=>{const t=m.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)),k=(0,t.marginDrops)(a,d(i,-14)).filter(e=>u.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{fullyCosted:l.size,costed:c,menu:f.menu,startMenu:h,trend:m.points.map(e=>({week:e.week,menu:e.menu})),dishes:b,drops:k,underTarget:f.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?b(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return y(n)},_e.clockChangesFromServer=function(e){return y(e.filter(e=>h.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:k(e.action,e.old_value),after:k(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 w}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:d(r,-6),to:r},a={from:d(r,-13),to:d(r,-7)},i={from:d(r,-29),to:r},l=(0,n.coversInRange)(o,s),c=(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:c.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=d(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:d(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,o,s=[]){const a={from:d(o,-6),to:o},i=(0,n.labourVsTakings)(e,s,t,r,a),l=e.filter(e=>e.date>=a.from&&e.date<=a.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:i.labour,takings7:i.gross,pct7:i.pct,days7:i.days,paidHours7:Math.round(l/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=v(e.members),r=v(e.stampsMonth),o=v(e.rewardsUsedMonth??e.rewardsMonth),s=v(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 d(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 c=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14,g=5;function p(e,n,r,o){const s=new Set;for(const a of r){const r=n[a.id];if(!r||!r.lines?.length)continue;if(null==a.ingCount||r.lines.length0||i.priceIsSuggested||s.add(a.id)}return s}const m={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'},h=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),b=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 k(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:b(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const y=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const w=30;const v=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1470,[908,906,1468]); +__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},1471,[]); +__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.useAssistantRequestInbox=x,_e.AssistantRequestsButton=function({go:e,testID:t}){const{visible:s,count:l}=x();return s?(0,b.jsx)(n.default,{style:{width:'100%',maxWidth:900,alignSelf:'center',paddingHorizontal:14,paddingTop:4,paddingBottom:8},children:(0,b.jsx)(o.Button,{testID:t??'assistant-requests-btn',label:l?`Assistant requests \xb7 ${l}`:'Assistant requests',accessibilityLabel:(0,p.assistantRequestsButtonLabel)(l),accessibilityHint:"Opens the list of changes your assistant has asked you to confirm or decline",kind:l?'primary':'secondary',onPress:()=>e('more','assistant-requests'),style:{minHeight:56}})}):null},_e.AssistantRequestsPage=function(){const{rows:e,load:t,visible:s}=x();if(!s)return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner can confirm or decline assistant changes, and only when an assistant is paired."})]});return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{gap:12,paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Each change waits for an owner to approve or decline it. Important changes ask a second time."}),(0,b.jsx)(w,{rows:e,onChanged:()=>{t()}})]})},_e.AssistantPendingCard=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(null),c=async()=>{try{r(await(0,l.assistantProposalsList)())}catch{r([])}};return(0,t.useEffect)(()=>{if(!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR)return;c();const t=setInterval(()=>{c()},2e4);return()=>clearInterval(t)},[e,s,n]),!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR?null:(0,b.jsx)(w,{rows:o,onChanged:()=>{c()},compact:!0})},_e.AssistantsPage=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),[s,r]=(0,t.useState)(''),[u,h]=(0,t.useState)(null),[p,x]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[A,I]=(0,t.useState)(null),[k,D]=(0,t.useState)(null),[C,S]=(0,t.useState)(null),[T,P]=(0,t.useState)(null),L=async()=>{try{P(await(0,l.assistantAccess)())}catch{P({plan:null,allowed:!1,reason:'Could not check this plan.'})}try{v(await(0,l.assistantList)())}catch{v([])}try{I(await(0,l.assistantProposalsList)())}catch{I([])}try{D(await(0,l.assistantAuditList)())}catch{D([])}};(0,t.useEffect)(()=>{e&&L()},[e]);const R=s.replace(/\D/g,''),$=!!T?.allowed,M=async()=>{x(!0),h(null);const e=await(0,l.assistantApprove)(R);x(!1),e.ok?(r(''),h({ok:!0,text:'Done. The assistant is paired. It can look things up and propose changes, which wait for an owner to confirm on their phone.'}),L()):h({ok:!1,text:e.message})},q=async(e,t)=>{x(!0),h(null);const s=await(0,l.assistantSetEnabled)(e.id,t);x(!1),s.ok?(h({ok:!0,text:t?`${e.label} is switched on.`:`${e.label} is switched off. It stays paired, and you can switch it on again.`}),L()):h({ok:!1,text:s.message})};return(0,b.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,b.jsx)(w,{rows:A,onChanged:()=>{L()}}):null,(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair your assistant"}),(0,b.jsx)(o.T,{center:!0,children:f}),(0,b.jsx)(o.T,{center:!0,children:"Ask your assistant, such as Grok Bot, to start CoverCharge sign-in. It will show 6 numbers. Only an owner of this venue can approve it. In the connected assistant it can answer questions about your venue and give advice from the data it is allowed to look up. It can propose a change; nothing is changed until an owner confirms it on their 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 a second time, with a plain warning of what is affected."}),!$&&T?(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-plan-blocked",children:T.reason||'Connecting an AI assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.'}):null,(0,b.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:s,onChangeText:e=>r(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,b.jsx)(o.Button,{testID:"assistant-approve",label:p?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs your AI assistant with this venue",disabled:!e||!$||p||6!==R.length,onPress:()=>{M()},style:{minHeight:56}}),e?null:(0,b.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,b.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!u,accessibilityLabel:u?.text,children:u?(0,b.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:u.ok?c.colours.goldLight:c.colours.amber,children:u.text}):null}),(0,b.jsx)(o.Muted,{center:!0,children:"Never send a personal app link to the bot. That link stays on your phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, it cannot read other venues, and it cannot change its own access or pairing."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(t=>(0,b.jsxs)(n.default,{testID:`assistant-row-${t.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:`${t.label} \xb7 ${!1===t.enabled?'switched off':'paired'}`}),(0,b.jsx)(o.Muted,{center:!0,children:`Since ${y(t.approvedAt)}. Last seen ${y(t.lastSeenAt)}.${t.ownerName?` Tied to ${t.ownerName}.`:''}`}),(0,b.jsx)(o.Toggle,{testID:`assistant-enabled-${t.id}`,label:"Assistant on",value:!1!==t.enabled,disabled:p||!e,onChange:e=>{q(t,e)},a11y:!1===t.enabled?`Switch on ${t.label}`:`Switch off ${t.label}`}),(0,b.jsx)(o.Button,{testID:`assistant-revoke-${t.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${t.label}`,onPress:()=>S(t),style:{minHeight:56}})]},t.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Activity log"}),(0,b.jsx)(o.Muted,{center:!0,children:"Everything this venue\u2019s assistants do is logged here, including look-ups. The assistant cannot change or skip this log."}),null===k?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):k.length?k.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-audit-${e.id}`,style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:e.detail||e.action}),(0,b.jsx)(o.Muted,{center:!0,children:`${y(e.at)}${e.actorName?` \xb7 ${e.actorName}`:''}`})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-audit-empty",children:"No activity yet."})]}),C?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>S(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,b.jsx)(o.T,{center:!0,children:`${C.label} stops working straight away. Any changes still waiting are cancelled. Your phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,b.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=C;S(null);const t=await(0,l.assistantRevoke)(e.id);h(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),L()},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>S(null),style:{minHeight:56}})]}):null]})};var t=_r(d[0]),s=e(_r(d[1])),n=e(_r(d[2])),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]);const y=e=>e?`${(0,r.niceDate)(new Date(e))} at ${(0,r.hm)(new Date(e))}`:'not yet',f='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.';function w({rows:e,onChanged:r,compact:u}){const h=(e??[]).filter(e=>'pending'===e.status),[f,w]=(0,t.useState)(null),[x,j]=(0,t.useState)(null),[v,A]=(0,t.useState)(null),I=async(e,t,n=!1)=>{w(e.id),j(null);const o=await(0,l.assistantProposalDecide)(e.id,t,n);if(w(null),o.ok){A(null);const e='decline'===t?'Declined. Nothing was changed.':'Done. The change has been made.';j(e),s.default.announceForAccessibility(e),r?.()}else j(o.message),s.default.announceForAccessibility(o.message)};return!h.length&&u?null:(0,b.jsx)(n.default,{testID:u?'assistant-pending-home':'assistant-pending-list',children:(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Waiting for an owner to confirm"}),e?h.length?h.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:8,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,alignItems:'center'},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,b.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${y(e.expiresAt)}.`:'']}):e.expiresAt?(0,b.jsx)(o.Muted,{center:!0,children:`Runs out at ${y(e.expiresAt)}.`}):null,e.canDecide?(0,b.jsxs)(n.default,{style:{gap:8,width:'100%',maxWidth:520,alignSelf:'center'},children:[(0,b.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:f===e.id?'Working\u2026':'Approve',accessibilityLabel:(0,p.assistantRequestActionLabel)('Approve',e.summary),accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!f,onPress:()=>{e.needsDoubleConfirm?A(e):I(e,'approve')},style:{minHeight:56}}),(0,b.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",accessibilityLabel:(0,p.assistantRequestActionLabel)('Decline',e.summary),disabled:!!f,onPress:()=>{I(e,'decline')},style:{minHeight:56}})]}):(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner of this venue can confirm or decline this on their phone."})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,b.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),(0,b.jsx)(n.default,{accessible:!0,accessibilityLiveRegion:"polite",accessibilityRole:"text",testID:"assistant-requests-status",style:{minHeight:x?void 0:0},children:x?(0,b.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:x}):null}),v?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>A(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,b.jsx)(o.T,{center:!0,accessibilityRole:"header",children:v.summary}),(0,b.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."}),v.warning?(0,b.jsx)(o.Muted,{center:!0,children:v.warning}):null,(0,b.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:f===v.id?'Working\u2026':'Yes, make this change',disabled:!!f,accessibilityLabel:`Yes, make this change: ${v.summary}`,onPress:()=>{I(v,'approve',!0)},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Go back",accessibilityLabel:`Go back without changing: ${v.summary}`,onPress:()=>A(null),style:{minHeight:56}})]}):null]})})}function x(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(0),[c,b]=(0,t.useState)(null),y=async()=>{try{const[e,t]=await Promise.all([(0,l.assistantList)(),(0,l.assistantProposalsList)()]);r((e??[]).length),b(t??[])}catch{r(0),b([])}};(0,t.useEffect)(()=>{if('owner'!==u.APP_VARIANT||u.IS_CAR||n||'owner'!==s||!e)return;y();const t=setInterval(()=>{y()},2e4);return()=>clearInterval(t)},[e,s,n]);const f=(c??[]).filter(e=>'pending'===e.status).length;return{visible:(0,p.canSeeAssistantRequests)({appVariant:u.APP_VARIANT,isCar:u.IS_CAR,inStaffApp:n,role:s,live:e,pairedCount:o}),count:f,rows:c,load:y,paired:o}}},1472,[17,264,85,777,899,863,804,856,1057,1473,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.assistantRequestActionLabel=function(t,s){const n=String(s||'this change').replace(/\s+/g,' ').trim().replace(/\.+$/,'');return`${t}: ${n||'this change'}`},e.assistantRequestsButtonLabel=function(t){const s=Math.max(0,Math.floor(Number(t)||0));return 1===s?'Assistant requests, 1 waiting':`Assistant requests, ${s} waiting`},e.canSeeAssistantRequests=function(t){return'owner'===t.appVariant&&!t.isCar&&!t.inStaffApp&&'owner'===t.role&&!!t.live&&(t.pairedCount??0)>0}},1473,[]); +__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"})]})}},1474,[817,1190,17,264,266,347,378,219,278,85,19,777,857,860,876,998,1036,1037,805,842,1034,1475,804,856,1057,1476,1479,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}}},1475,[1034]); +__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=C,_e.importQuestionnaireAccounts=B,_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. 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)(i.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:l}=(0,x.useCtx)(6e4),j='owner'===n,I=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],M=(0,p.useQuestionnaire)(e),{mark:P}=(0,p.useProvenance)(e),[A,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(M?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!I.some(n=>n.provider===e.provider)),[M,I]),W=(M?.accounts??[]).some((e,n)=>P('accounts',n,'provider'));return(0,y.jsxs)(i.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)(i.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:P('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:l})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>M&&B(e,M,l)}):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:`${I.length}`})]}),I.length?I.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(M?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(i.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)(i.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:P('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:T[e.status].kind,label:T[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)(C,{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=I.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:A,owner:j,by:l,onClose:()=>z(null)}),$?(0,y.jsx)(k,{rid:e,c:$,by:l,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),l=e(r(d[4])),i=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)(i.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 C({rid:e,compact:n}){const{role:o,me:l}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,C]=(0,t.useState)({}),[B,I]=(0,t.useState)(null),T=u.useAccounts.getState();return(0,y.jsxs)(i.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)(i.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)(i.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)(i.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)(i.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>C({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(i.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:()=>T.update(e,o.id,{accountNo:u},l,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>I(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>T.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:l})})}),(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)}),B?(0,y.jsx)(k,{rid:e,c:B,by:l,onClose:()=>I(null)}):null]})}function k({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)(i.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:["CoverCharge will stop listing ",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 B(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const l of n.accounts??[])o.some(e=>e.provider===l.provider)||s.add(e,{provider:l.provider,handle:l.handle,status:'listed',from:'questionnaire',addedBy:t})}function I({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,C]=(0,t.useState)(p?.handle??''),[k,B]=(0,t.useState)(p?.customName??''),[I,T]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const M=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${M?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(l.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(i.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:M?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),M?(0,y.jsx)(a.Field,{label:"Service name",value:k,onChangeText:B,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:()=>T(!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."]})]}),I?(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, 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:C,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:M?'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:M&&k.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:M?k.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:M&&!k.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)(i.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)(i.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)(i.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 T={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)(I,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1476,[812,17,362,385,278,85,777,1477,1478,804,1474,1057,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)},1477,[]); +__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)}))},1478,[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})]})}},1479,[17,385,85,777,860,1478,998,842,1480,1475,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'},1480,[]); +__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}},1481,[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])},1482,[1185,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1182,1445,1162,860,1186,853,1184,884,1361,998,843,1115,1199,1206,1071,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']}},1483,[17,1055,85,409,777,858,1141,1140,861,863,804,876,1184,1057,1149,1145,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}))},1484,[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]})]})}},1485,[805,1420,843,1394,17,85,777,858,860,866,845,851,1160,1105,863,804,1184,1057,1161,1162,853,1426,848,900,1486,8]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const a=!!e.settings.takeawayPaused;return(0,u.jsx)(l.Card,{highlight:a?r.colours.red:void 0,children:(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(l.T,{weight:"semibold",children:a?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,u.jsx)(l.Muted,{children:a?'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,u.jsx)(l.Toggle,{testID:"takeaway-pause",label:a?'Resume':'Pause',value:!a,onChange:a=>t.useStore.getState().updateSettings(e.id,{takeawayPaused:!a})})]})})},_e.TakeawayMenuList=function({me:e}){const[s,t]=(0,a.useState)(!1),c=(0,o.useStaffTakeaway)(e=>e.rows),h=(0,o.useStaffTakeaway)(e=>e.canSet),f=(0,o.useStaffTakeaway)(e=>e.busy),w=(0,o.useStaffTakeaway)(e=>e.error),y=(0,o.useStaffTakeaway)(e=>e.loadedAt);(0,a.useEffect)(()=>{s&&(0,o.loadStaffTakeaway)(!0)},[s]);const k=c?Object.values(c).sort((e,a)=>e.section.localeCompare(a.section)||e.dish.localeCompare(a.dish)):null,j=k?.filter(e=>e.onMenu).length??0,x=y>0&&null===c;return(0,u.jsxs)(l.Card,{children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",k?` \xb7 ${j} of ${k.length} available`:'']}),(0,u.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Hide':'Choose dishes',onPress:()=>t(!s),testID:"takeaway-menu"})]}),s?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(l.Muted,{children:"The whole menu shows on the takeaway page. Switch off what can\u2019t be done for takeaway today: guests see it as \u201cNot available for takeaway today\u201d. A dish also needs Head Chef allergen sign-off and a price."}),!h&&k?(0,u.jsx)(l.Muted,{children:"Only the Head Chef, a manager or an owner can change this."}):null,x?(0,u.jsx)(l.Banner,{kind:"warn",children:"Connect to the venue to see the takeaway menu."}):null,w?(0,u.jsx)(l.Banner,{kind:"warn",children:w}):null,k||x||w?null:(0,u.jsx)(l.Muted,{children:"Loading\u2026"}),(k??[]).map(a=>(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsxs)(l.T,{size:14,children:[a.dish,a.pricePence?` \xb7 ${(0,d.gbp)(a.pricePence)}`:'']}),(0,u.jsxs)(l.Row,{gap:4,children:['Specials board'===a.section?(0,u.jsx)(l.Badge,{kind:"gold",label:"Special"}):null,a.soldOut?(0,u.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,a.signedOff?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),a.pricePence?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),h?(0,u.jsx)(l.Toggle,{label:"Available for takeaway",a11y:`Available for takeaway, ${a.dish}`,value:a.onMenu,disabled:f===a.itemId,onChange:s=>{(0,o.setTakeawayAvailable)(a.itemId,s,e).catch(()=>{})}}):(0,u.jsx)(l.T,{size:14,colour:a.onMenu?r.colours.gold:r.colours.muted,children:a.onMenu?'Available':'Not today'})]},a.itemId))]}):null]})};var e,a=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),t=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),u=_r(_d[7])},1486,[17,85,777,858,851,1159,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 Ce}});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]),w=_r(d[16]),v=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),I=_r(d[22]),M=_r(d[23]),G=_r(d[24]),O=_r(d[25]),E=_r(d[26]),B=_r(d[27]),x=_r(d[28]),D=_r(d[29]),N=_r(d[30]),L=(e=N)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),q=_r(d[33]),Q=_r(d[34]),F=_r(d[35]),U=_r(d[36]),V=_r(d[37]),W=_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]),ye=_r(d[64]);const Ce=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},me=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:me,C:v.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=>me(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:me,C:O.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:me,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=>me(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:me,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:me,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:me,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:me,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:me,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:me,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:me,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:E.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:me,C:G.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:me,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:B.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:B.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:me,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:me,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:me,C:w.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:B.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:B.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:B.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:me,C:B.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:me,C:B.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:me,C:B.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:me,C:B.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:me,C:B.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:B.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:me,C:B.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:B.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:()=>Ce(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:me,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:me,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:me,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:me,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:me,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:me,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const Se=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(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:Se,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:Se,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:me,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:me,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:me,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:me,C:F.DisplaySettingsPage}]);const ke=e=>'owner'===e||'manager'===e;U.ASSISTANT_AVAILABLE&&V.ASSISTANT_UI&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:ke,C:U.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:ke,C:U.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:Y.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair your own AI assistant with a 6-digit code, switch it off, or unpair it',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantsPage}]),(0,y.register)([{id:'assistant-requests',title:'Assistant requests',sub:'Confirm or decline changes your assistant has proposed',group:'Start here',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantRequestsPage}]);const we=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:I.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:I.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:I.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:I.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:I.InsightsClockPage}]);const Pe=()=>{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)},Re=e=>we(e)&&Pe();(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:we,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:Re,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:Re,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:Re,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:we,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,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:we,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:me,C:z.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:me,C:z.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:me,C:z.Outbox}]);const Ae=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:Ae,C:J.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:J.optinsAllowed,C:J.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Ae,C:$.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Ae,C:K.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:Ae,C:X.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:Ae,C:Z.OrderSheetSettings},...ee.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Ae,C:(0,K.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Ae,C:te.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Ae,C:se.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:me,C:se.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Ae,C:se.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:Ae,C:ae.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:me,C:ie.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:me,C:ie.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:me,C:ie.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:me,C:re.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos and Show me where',group:'Start here',can:me,C:oe.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:me,C:ue.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:me,C:le.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:le.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ce.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ge.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:we,C:function(){const{rid:e,today:t}=(0,de.useCtx)(6e4);return L.default.createElement(ge.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(pe.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:me,C:ne.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(he.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:me,C:be.NightlyReportPage}]),(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:ye.UseOnComputerPage}]),(0,y.register)([{id:'support',title:'Customer support',sub:'Send a message or a picture to CoverCharge',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:fe.SupportChatPage}])},1487,[822,1050,856,1488,876,920,909,816,866,1490,1497,1499,1458,1500,1501,1503,1504,1161,1483,1505,1506,1507,1466,1202,1193,1485,1508,1456,1509,1510,17,1199,1182,1457,1445,1459,1515,1214,1521,1522,1472,1523,1448,1433,1524,1463,1525,886,1526,1527,1529,1188,1474,1530,1394,1476,1542,1081,1057,1203,1153,1546,1549,1552,1554]); +__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)}},1488,[17,378,219,385,85,19,777,1026,1340,876,804,1489,1190,1484,1057,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}))},1489,[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}},1490,[812,1454,17,851,85,777,876,804,1057,884,885,1491,899,916,1031,1452,1492,1493,1495,996,1496,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},1491,[]); +__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])},1492,[812,17,85,777,804,876,1356,1355,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])},1493,[17,85,777,1494,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},1494,[831,928,899,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]},1495,[17,85,777,804,914,1022,899,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])},1496,[928,899]); +__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 h}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LINE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LITE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_TERM",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return C}}),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 U}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return $}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),h=(0,u.trialStatus)((0,l.defaultSimStart)(),e),[y,f]=(0,t.useState)(!1);return i.CAN.billing(n)?y?(0,p.jsx)(q,{onBack:()=>f(!1)}):(0,p.jsxs)(o.default,{style:{gap:10},children:[(0,p.jsx)(s.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,p.jsxs)(s.Card,{highlight:d.colours.gold,children:[(0,p.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,p.jsxs)(s.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[S,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-early-term",children:D})]}),(0,p.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:Y.map(([e,t])=>(0,p.jsxs)(o.default,{testID:e===b?'plan-early-guest-app':e===x?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,p.jsxs)(s.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,p.jsx)(s.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,p.jsx)(s.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,N,M,z,'Usual price',''],['plan-usual-pro',E,R,U,G,'Usual price',''],['plan-superpro',k,C,F,V,'1-year contract','No hardware included.']].map(([e,t,n,l,i,u,c])=>(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,p.jsxs)(s.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsx)(s.Muted,{center:!0,children:S}),(0,p.jsx)(s.Muted,{center:!0,children:l}),'plan-superpro'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-superpro-epos-line",children:B}):null,i.map(e=>(0,p.jsxs)(s.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),'plan-usual-lite'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-lite-ai",children:I}):null,c?(0,p.jsx)(s.Muted,{center:!0,children:c}):null]})},e)),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-terms",children:$}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>f(!0),style:{alignSelf:'center'}}),(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,p.jsxs)(s.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,p.jsx)(s.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,p.jsx)(s.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,p.jsx)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{children:"Free trial"}),(0,p.jsxs)(s.T,{weight:"bold",colour:d.colours.gold,children:[h.daysLeft," day",1===h.daysLeft?'':'s'," left"]})]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-h.daysLeft/h.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,p.jsxs)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'center'},gap:8,children:[(0,p.jsx)(s.T,{weight:"semibold",children:"Free customer support"}),(0,p.jsx)(s.Badge,{kind:"gold",label:"Included"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,p.jsx)(s.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},s=r(_d[2]),l=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]);const h=!0,y='Early adopter offer, usual prices, free trial, set-up guide',f='. 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',b='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',j='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',x='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.',_='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',v='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',I='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer.',O='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',S='+ VAT if applicable, per venue',L='Customer & Takeaway App',E='Full Restaurant Pro App',k='SuperPro',N='\xa349',R='\xa399',C='\xa3149',M='The lite version: core features for smaller venues.',U='Every feature, every app.',F='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',B='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.',D='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.',Y=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',D],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[b,A],['Free customer support','For the length of your subscription.'],[x,T],[v,v],[j,w]],z=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',b,P,j],G=['Owner dashboard and admin','Supplier links',x,v,b,P,j],V=['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',_,v,b,P,j],$='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. AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',K=[['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 q({onBack:e}){const[n,l]=(0,t.useState)([]);return(0,p.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,p.jsx)(s.H2,{children:"Set-up guide"}),(0,p.jsxs)(s.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",K.length," done."]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/K.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),K.map(([e,t],i)=>{const u=n.includes(i);return(0,p.jsx)(s.Card,{children:(0,p.jsxs)(s.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.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,p.jsx)(s.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,p.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(s.T,{weight:"semibold",children:e}),(0,p.jsx)(s.Muted,{children:t}),(0,p.jsx)(s.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>l(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,p.jsx)(s.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1497,[17,85,777,835,876,1498,804,1057,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'}},1498,[]); +__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]})]})]})}},1499,[805,1033,891,1420,813,812,822,1263,1440,17,385,393,85,864,777,858,876,845,851,863,804,1184,1057,1161,1445,1221,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])},1500,[843,17,85,1162,777,858,845,853,863,804,1184,1057,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])},1501,[1039,17,85,1502,814,857,777,876,804,1057,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}})},1502,[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])},1503,[17,1155,847,1057,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])},1504,[17,1032,1057,899,915,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])},1505,[17,1400,1057,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=b,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,u.useCtx)(6e4),n=(0,o.useBookings)(e),i=(0,d.useCashUp)(e=>e.cashUps),[j,w]=(0,s.useState)('day'),f=(0,h.hasAnyTakings)(i,e),k=(0,l.coverOverridesFor)(e),v=(0,h.dayRows)(i,n,e,t,14,k),$=(0,h.weekRows)(i,n,e,t,8,k),T=(0,h.averageSph)(v),S=(e,s,t,l,n)=>(0,p.jsxs)(a.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:c.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===l?'no takings entered':`spend per head ${l}`}, ${t}${n?`, ${n}`:''}`,children:[(0,p.jsx)(r.T,{center:!0,children:s}),(0,p.jsx)(r.T,{center:!0,colour:c.colours.muted,children:t}),(0,p.jsx)(r.T,{center:!0,weight:"semibold",colour:'No takings entered'===l?c.colours.muted:c.colours.goldLight,size:'No takings entered'===l?13:16,children:l}),n?(0,p.jsx)(r.Muted,{center:!0,children:n}):null]},e);return(0,p.jsxs)(a.default,{style:{gap:12},testID:"sph-screen",children:[(0,p.jsx)(r.Muted,{children:"Tip: spend per head is takings \xf7 Covers. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,p.jsxs)(r.Card,{highlight:c.colours.gold,children:[(0,p.jsx)(r.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==T?(0,p.jsx)(r.T,{size:22,weight:"semibold",colour:c.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,p.jsxs)(r.T,{size:34,weight:"bold",colour:c.colours.goldLight,testID:"sph-avg",children:[x(T)," ",(0,p.jsx)(r.T,{size:16,colour:c.colours.muted,children:"per head"})]}),(0,p.jsx)(r.Muted,{children:f?'Only days with a cash up are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has card and cash totals.'})]}),(0,p.jsxs)(r.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(r.Chip,{testID:"sph-day",label:"By day",selected:'day'===j,onPress:()=>w('day')}),(0,p.jsx)(r.Chip,{testID:"sph-week",label:"By week",selected:'week'===j,onPress:()=>w('week')})]}),'day'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by day"}),(0,p.jsx)(b,{testID:"sph-trend-day",label:"Spend per head trend by day",points:v.map(e=>({label:y(e.date),value:e.sph}))}),[...v].reverse().map(e=>S(e.date,y(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':x(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${x(e.foodPh)}, drink ${x(e.drinkPh)} per head`:void 0))]}):null,'week'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,p.jsx)(b,{testID:"sph-trend-week",label:"Spend per head trend by week",points:$.map(e=>({label:`w/c ${y(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...$].reverse().map(e=>S(e.weekStart,`w/c ${y(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':x(e.sph)))]}):null,(0,p.jsx)(r.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=_r(_d[1]),a=e(_r(_d[2])),n=_r(_d[3]),i=e(n),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]);const x=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function b({points:e,testID:l,label:o}){const[d,h]=(0,s.useState)(320),[u,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,l]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,u)),w=Math.max(0,j-b),f=e.slice(w,j),k=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)),T=e=>38+e*(k-76)/Math.max(1,f.length-1),S=e=>140-e/$*106,L=[];let D=[];f.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} ${x(e.value)}`).join(', ');return(0,p.jsxs)(a.default,{testID:l,onLayout:e=>h(e.nativeEvent.layout.width),style:{gap:8},children:[(0,p.jsxs)(a.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,p.jsx)(i.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,p.jsx)(n.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:c.colours.muted,children:x($*e/4)},e))}),(0,p.jsxs)(i.default,{width:k,height:170,children:[[0,1,2,3,4].map(e=>(0,p.jsx)(n.Line,{x1:0,x2:k,y1:S($*e/4),y2:S($*e/4),stroke:c.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,p.jsx)(n.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:c.colours.gold,strokeWidth:2.5},s)),f.map((e,s)=>(0,p.jsx)(t.default.Fragment,{children:null==e.value?(0,p.jsx)(n.Circle,{cx:T(s),cy:140,r:2,fill:"#444"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.Circle,{cx:T(s),cy:S(e.value),r:4,fill:c.colours.goldLight}),(0,p.jsx)(n.Text,{x:T(s),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:c.colours.goldLight,children:x(e.value)})]})},w+s))]})]}),(0,p.jsx)(a.default,{style:{flexDirection:'row',gap:12},children:f.map((e,s)=>(0,p.jsxs)(a.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':x(e.value)}`,children:[(0,p.jsx)(r.T,{center:!0,size:12,colour:c.colours.muted,children:e.label}),(0,p.jsx)(r.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?c.colours.muted:c.colours.goldLight,children:null==e.value?'No takings entered':x(e.value)})]},w+s))}),(0,p.jsxs)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(r.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,p.jsx)(r.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))})]})]})}},1506,[17,1467,85,780,777,858,1008,1469,804,1057,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])},1507,[17,85,1349,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])},1508,[17,776,1057,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:a,role:I,today:x,signedIn:j}=(0,b.useCtx)(),[D,P]=(0,t.useState)('today'),R=(0,r.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),W=(0,c.useOwner)(e=>(0,c.liveAttendance)(e.attendance)),C=(0,b.useHourly)(),S=(0,$.useReviews)(e=>e.reviews),N=(0,u.canSeeTakingsStats)(I,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,v.ensureReviewSync)(e,'manage')},[e]);const M=(0,u.rangeFor)(x,D),L=(0,u.previousRange)(x,D),G=(0,t.useMemo)(()=>R.filter(s=>s.restaurantId===e),[R,e]),_=(0,u.coversInRange)(G,M),O=(0,u.coversInRange)(G,L),B=(0,u.noShowRate)(G,M,e),F=(0,u.noShowRate)(G,L,e),A=(0,u.cancelRate)(G,M,e),H=(0,u.cancelRate)(G,L,e),V='today'===D?(0,h.laterTodayCovers)(G,x):0,z=(0,u.takingsInRange)(T,e,M),U=(0,u.takingsInRange)(T,e,L),E=(0,s.coverOverridesFor)(e),Y=(0,u.spendPerHeadInRange)(T,G,e,M,E),q=(0,u.spendPerHeadInRange)(T,G,e,L,E),J=(0,u.tipsInRange)(T,e,M),K=(0,u.tipsInRange)(T,e,L),Q=(0,t.useMemo)(()=>W.filter(e=>'confirmed'===(0,c.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,b.paidMins)(e,a).paid,ratePence:C[e.staffId]??0})),[W,C,a]),X=(0,t.useMemo)(()=>W.filter(e=>'awaiting'===(0,c.attStatus)(e)).map(e=>e.date),[W]),Z=(0,u.labourVsTakings)(Q,X,T,e,M),ee=(0,u.labourVsTakings)(Q,X,T,e,L),se=(0,u.tipsVsTakings)(T,e,M),te=(0,u.firstVisitDate)(G,e),ae=(0,u.repeatGuestPct)(G,M,e),ne=(0,u.repeatGuestPct)(G,L,e),ie=(0,u.reviewAverage)(S.filter(s=>s.restaurantId===e),M),oe='today'===D?'today':'week'===D?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(o.T,{weight:"semibold",size:y.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(o.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)(o.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(o.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:D===e.id,onPress:()=>P(e.id)},e.id))}),(0,f.jsx)(w,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${oe}`,value:(0,u.pctLabel)(_.walkInPct),detail:_.empty?void 0:`${_.walkIns} walk-in covers \xb7 ${_.bookings} booked covers \xb7 ${_.total} total`,change:(0,u.changeWords)((0,u.changePct)(_.walkInPct,O.walkInPct),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${oe}`,value:(0,u.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(B.rate,F.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${oe}`,value:(0,u.pctLabel)(A.rate),detail:A.empty?void 0:`${A.count} cancelled out of ${A.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(A.rate,H.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-covers",label:`Covers \xb7 ${oe}`,value:_.empty?null:String(_.total),detail:_.empty?void 0:'today'===D?V>0?`${V} more ${1===V?'cover':'covers'} booked for later today`:'No more bookings for later today':`${_.walkIns} walk-in \xb7 ${_.bookings} booked`,change:(0,u.changeWords)((0,u.changePct)(_.empty?null:_.total,O.empty?null:O.total),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${oe}`,value:(0,u.pctLabel)(ae.rate),detail:ae.empty?void 0:`${ae.count} of ${ae.of} identifiable seated or finished parties had visited before${te?` (visits on record from ${(0,u.ukDay)(te)})`:''}`,change:(0,u.changeWords)((0,u.changePct)(ae.rate,ne.rate),D),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(w,{testID:"insights-reviews",label:`Reviews \xb7 ${oe}`,value:ie.empty?null:`${ie.avg} / 5`,detail:ie.empty?void 0:`Average of ${ie.count} published review${1===ie.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(w,{testID:"insights-tips",label:`Tips (team total) \xb7 ${oe}`,value:(0,u.moneyGbp)((0,u.completeTotal)(J,J.tips)),detail:null==J.tips?void 0:N&&null!=se.pct?`${J.days} cash-up day${1===J.days?'':'s'} \xb7 ${(0,u.pctLabel)(se.pct)} of takings on the ${se.days} day${1===se.days?'':'s'} with takings`:`${J.days} cash-up day${1===J.days?'':'s'}`,change:J.missing||K.missing?null:(0,u.changeWords)((0,u.changePct)(J.tips,K.tips),D),empty:J.missing?(0,u.missingWords)(J.missing,'tips figure',J.missingDates):'No tips entered in this period'}),N?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(w,{testID:"insights-takings",label:`Takings \xb7 ${oe}`,value:(0,u.moneyGbp)(z.gross),detail:null==z.gross?void 0:`Card + cash \u2212 card tips, from ${z.days}${z.missing?` of ${z.days+z.missing}`:''} confirmed cash-up day${z.days+z.missing===1?'':'s'}${z.missing?`. ${(0,u.takingsMissingWords)(z.missingDates)}`:''}`,change:z.missing||U.missing?null:(0,u.changeWords)((0,u.changePct)(z.gross,U.gross),D),empty:z.missing?(0,u.missingWords)(z.missing,'card or cash total',z.missingDates):'No takings entered in this period'}),(0,f.jsx)(w,{testID:"insights-sph",label:`Spend per head \xb7 ${oe}`,value:(0,u.moneyGbp)(Y.sph),detail:null==Y.sph?void 0:`\xa3${Y.gross.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})} takings \xf7 ${Y.covers} seated or finished covers, on ${Y.days} day${1===Y.days?'':'s'} with both${Y.noCovers?`. ${Y.noCovers} day${1===Y.noCovers?'':'s'} with takings and no Covers (a function, say) count${1===Y.noCovers?'s':''} in takings, not here`:''}`,change:(0,u.changeWords)((0,u.changePct)(Y.sph,q.sph),D),empty:Y.noCovers?'Spend per head needs a day with both takings and seated or finished Covers':'No takings entered, so no spend per head'}),(0,f.jsx)(w,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${oe}`,value:(0,u.pctLabel)(Z.pct),detail:null!=Z.pct?`${(0,u.moneyGbp)(Z.labour)} signed-off wages \xf7 ${(0,u.moneyGbp)(Z.gross)} takings, on the ${Z.days} day${1===Z.days?'':'s'} with takings${z.missing?`. ${z.missing} cash up${1===z.missing?'':'s'} with no card or cash total left out`:''}${Z.awaiting?`. ${Z.awaiting} shift${1===Z.awaiting?'':'s'} on those days still need${1===Z.awaiting?'s':''} signing off, not counted yet`:''}`:void 0,change:(0,u.changeWords)((0,u.changePct)(Z.pct,ee.pct),D),empty:j||Object.keys(C).length?null==Z.gross?'Not enough data: no cash up in this period has a card or cash total':'Not enough data: no signed-off hours with a pay rate on the days with takings':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(o.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-not-shown",children:(0,f.jsx)(o.Muted,{center:!0,children:u.NOT_SHOWN_YET})})]})};var e,s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=(e=a)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),y=_r(d[10]),v=_r(d[11]),$=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function w({testID:e,label:s,value:t,detail:a,change:r,empty:l}){const c=!!r&&r.startsWith('Up'),h=!!r&&r.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.Muted,{center:!0,children:s}),null==t?(0,f.jsx)(o.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:l}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.T,{testID:`${e}-value`,weight:"semibold",size:y.font.hero,colour:y.colours.gold,center:!0,children:t}),a?(0,f.jsx)(o.Muted,{center:!0,children:a}):null,r?(0,f.jsx)(o.T,{testID:`${e}-change`,center:!0,colour:c?y.colours.goldLight:h?y.colours.muted:y.colours.text,children:r}):null]})]})})}},1509,[1467,17,85,777,858,1008,876,1055,1468,899,804,1242,1243,1057,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]})}},1510,[805,1420,812,822,843,1511,1439,1489,1228,841,1263,899,1512,1514,1440,17,1098,1497,13,385,85,864,1281,777,858,876,851,866,1105,1252,863,804,1184,1057,1139,869,1458,853,1026,1155,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)},1511,[843,17,85,777,845,851,1154,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)}}})]})}},1512,[899,17,264,219,85,1281,777,1260,1263,804,1513,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},1513,[17,219,85,777,1260,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'})})}},1514,[805,1420,17,85,777,851,1260,1261,1262,899,1263,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}),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'}]},1515,[812,891,779,869,1217,17,378,219,385,278,85,831,777,1098,858,876,1516,1520,804,1057,1071,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]}})})},1516,[1517,1519,1518]); +__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)}},1517,[843,1518]); +__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'}},1518,[]); +__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}},1519,[1517,1218]); +__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},1520,[869,824,831,834]); +__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})}},1521,[17,1212,1157,1213,1225,1057,1175,847,856,993,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'},1522,[17,85,777,899,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=v,_e.SmsBubble=C,_e.AlertSettings=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=(0,p.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,p.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,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,k.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,k.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>p.useAlerts.getState().setPrefs({muted:!e})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,y.chime)('bright')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,y.lowChime)(.6)})]}),(0,k.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,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,k.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),p.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindChip,{kind:e,size:30}),(0,k.jsx)(c.default,{style:{flex:1},children:(0,k.jsx)(h.Toggle,{label:p.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>p.useAlerts.getState().setType(e,s)})})]},e))]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,k.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,k.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,k.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${p.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,p.sendTestAlert)(s,e)},e))})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,k.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,k.jsx)(h.Muted,{children:r}),(0,k.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>p.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,k.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,p.requestSystemPermission)()),p.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,p.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,k.jsx)(h.Muted,{children:(0,p.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,k.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,k.jsx)(w.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindIcon,{kind:"email"}),(0,k.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,k.jsx)(h.Badge,{kind:"neutral",label:p.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,k.jsx)(h.Muted,{children:p.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${p.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,k.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,T.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,j.templatesFor)(r),[r]),p=(0,x.useAssistant)(e=>e.enabled)&&b.ASSISTANT_UI,[y,w]=(0,n.useState)('booking'),[A,M]=(0,n.useState)('sms'),B=u[y],I=s=>m.useStore.getState().setTemplate(e,y,s),R=Object.fromEntries(j.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===y?(0,j.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,j.bookingVars)({...S,date:o},s),N=(0,j.toGsm)((0,j.fill)(B.sms,L.sms)),_=(0,j.fill)(B.subject,L.email),D=(0,j.emailHtml)((0,j.fillEmailText)(B.body,L.email),{venue:s.name,preheader:_}),O=!!r?.[y],V=s.settings;return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:j.PREVIEW_BANNER}),(0,k.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,k.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(j.DEFAULT_TEMPLATES).map(e=>(0,k.jsx)(h.Chip,{label:j.TEMPLATE_LABEL[e].title,selected:y===e,onPress:()=>w(e)},e))}),(0,k.jsx)(h.Muted,{children:j.TEMPLATE_LABEL[y].when}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,k.jsxs)(h.Muted,{children:[(0,j.smsParts)(N).chars," characters"]})]}),(0,k.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:B.sms,onChangeText:e=>I({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,j.smsParts)(N).chars>300?(0,k.jsx)(h.T,{size:13,colour:f.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,k.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:B.subject,onChangeText:e=>I({subject:e}),style:h.styles.input}),(0,k.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,k.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:B.body,onChangeText:e=>I({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,k.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[p?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>I(P(B))}):null,O?(0,k.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,y,null)}):null]}),p?(0,k.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,k.jsxs)(h.Muted,{children:["Placeholders: ",j.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:"Text",selected:'sms'===A,onPress:()=>M('sms')}),(0,k.jsx)(h.Chip,{label:"Email",selected:'email'===A,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,k.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,k.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===y?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===A?(0,k.jsx)(C,{text:N,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),_]}),(0,k.jsx)(v,{html:D})]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,k.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,k.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:V.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,k.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!V.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,k.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,T.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),b=t.filter(e=>'all'===l||e.channel===l);return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:f.colours.gold,borderRadius:12,padding:12},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:f.colours.gold,children:(0,j.isLive)()?'Live: messages are sent through your text and email service.':j.PREVIEW_BANNER}),(0,j.isLive)()?null:(0,k.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,k.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,k.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),b.length?null:(0,k.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),b.map(e=>(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,k.jsxs)(h.T,{weight:"semibold",children:[A[e.kind]," \xb7 ",e.ref]})]}),(0,k.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,k.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,k.jsx)(h.T,{size:13,colour:'sent'===e.status?f.colours.ok:'failed'===e.status?f.colours.red:f.colours.amber,children:(0,j.statusLabel)(e)})]}),'sms'===e.channel?(0,k.jsx)(C,{text:e.body}):u===e.id?(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),e.subject]}),(0,k.jsx)(v,{html:e.html??'',height:560})]}):(0,k.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,k.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]),k=_r(d[18]);function v({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 C({text:e,to:t}){const l=(0,j.smsParts)(e);return(0,k.jsxs)(c.default,{style:{gap:4},children:[t?(0,k.jsxs)(h.Muted,{children:["To ",t]}):null,(0,k.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,k.jsx)(h.T,{size:15,children:e})}),(0,k.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const S={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 P(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 A={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1523,[813,812,822,17,219,385,85,777,1230,858,1520,1214,848,1232,1018,804,1027,1057,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:n,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,b=n.settings,x=(0,r.bookingRulesOf)(n),f=(0,o.usePlan)(g),j=(f?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...b.bookingRules??{},...x,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(n),M=(0,d.depositOf)(b),R=b.reservables??(0,i.reservablesOf)(n),O=(0,r.accessGuideOf)(n),[I,A]=(0,t.useState)(null),D=(e,t)=>T({largeGroups:x.largeGroups.map((n,s)=>s===e?{...n,...t}:n)});return(0,y.jsxs)(s.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."}),I?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:I}):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:b.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)(n)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(n)} 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."}),x.largeGroups.map((e,t)=>(0,y.jsxs)(s.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=>D(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>D(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=>D(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:x.largeGroups.filter((e,n)=>n!==t)})}):null]},t)),x.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=x.largeGroups[x.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...x.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:j.map(e=>{const t=x.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(x.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:x.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)(x,n.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(x.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(x.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:x.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!==b.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:x.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),x.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,x.onlineTableMins.map((e,t)=>(0,y.jsxs)(a.Muted,{center:!0,testID:`rules-table-min-${t}`,children:[(0,r.onlineTableMinLine)(e),". Staff can still book them for fewer."]},t)),(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:b.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:M.on&&M.perPersonPence>0?`${w(M.perPersonPence)} per adult for ${M.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),R.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:x.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:x.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:x.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:x.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:x.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:x.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}),A('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:n}=(0,k.useCtx)(6e4),o=T(n),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,b.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,f.isSupabaseConfigured)())return;let e=!0;try{(0,x.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:n})=>{e&&!n&&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)(s.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,f.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,x.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:j.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),n=_r(_d[1]),s=(e=n)&&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]),b=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),j=_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(b.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()},1524,[17,85,777,858,998,1079,1055,841,1105,1252,889,876,920,899,928,971,804,1057,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)})]})]})}},1525,[17,385,85,777,876,1000,851,1001,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]})}},1526,[17,219,385,85,409,777,804,1378,857,1382,863,899,1383,1057,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})},1527,[820,896,1456,17,219,85,777,816,876,895,1000,897,899,1528,804,880,1163,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'}},1528,[]); +__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])},1529,[17,85,777,804,1435,1511,1057,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=w,_e.HelpPage=function({go:e}){const[s,o]=(0,a.useState)(''),[r,h]=(0,a.useState)(null),[p,x]=(0,a.useState)(null),w=(0,a.useMemo)(()=>[...c.HELP,...m],[]),j=(0,a.useMemo)(()=>s.trim()?(0,u.searchHelp)(w,s,10).map(e=>e.a):w.filter(e=>!r||e.topic===r),[s,r,w]);return(0,f.jsxs)(i.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(i.default,{style:[l.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(l.T,{colour:y.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:o,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:y.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(n.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>o('')}):null]}),s?(0,f.jsx)(l.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)(l.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(l.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,n)=>(0,f.jsx)(b,{a:t,go:e,open:p===t.id||!!s&&0===n&&null===p,onToggle:()=>x(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(l.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",colour:y.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(l.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(l.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=function({go:e}){const{rid:t,today:s}=(0,x.useCtx)(6e4),n={rid:t,today:s,go:(t,s)=>e(t,s??null)},[o,r]=(0,a.useState)(''),[h,u]=(0,a.useState)(null),[m,b]=(0,a.useState)(null),C=async()=>{const e=o.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,n);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...j(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(i.default,{testID:"ask-assistant",children:(0,f.jsxs)(l.Card,{highlight:y.colours.gold,children:[(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(i.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(l.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:o,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:C,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(l.Button,{label:"Ask",testID:"assistant-ask",disabled:!o.trim(),onPress:C,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(l.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)(l.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(k,{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,n,!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,m?(0,f.jsxs)(i.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(l.Banner,{kind:'done'===m.kind?'success':'error'===m.kind?'warn':'demo'===m.kind?'demo':'info',title:m.text}),m.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>w(s,e)}):null]},t)})]}):null,(0,f.jsx)(l.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),o=e(_r(d[4])),i=e(_r(d[5])),l=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),y=_r(d[12]),x=_r(d[13]),f=_r(d[14]);const m=[{id:'ai-assistant-pairing',kind:'faq',topic:'Accounts',title:'Can I connect my own AI assistant?',keywords:['assistant','ai','pair','pairing','grok','bot','unpair','approve','draft','log'],body:'AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. In the connected assistant, it can answer questions about your venue and give advice from the venue data it is allowed to look up. It can draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged, including look-ups. Open More \u203a Account \u203a Assistants, as an owner, on Full Restaurant Pro, SuperPro or the early adopter offer. It is not included with Customer & Takeaway App, and there is no AI assistant on the Display app.',showMe:{tab:'more',page:'assistants',target:{testID:'assistants-page'},hint:'Pair, switch off or unpair an assistant here. Owners only.'}},{id:'customer-support',kind:'faq',topic:'Accounts',title:'How do I contact CoverCharge support?',keywords:['support','customer support','help','email','picture','photo','screenshot','contact','covercharge'],body:'Customer support is at the very bottom of Home, and at the bottom of More, as an owner. Write a message, attach one picture if you like (a photo or a screenshot), and tap Send to CoverCharge. It is sent with your venue name, your name and email, and the app version. You will see \u201cSent. We\u2019ll reply by email.\u201d if it went through, or an error with a way to try again. There is no Customer support on the Display, Staff, Front of House or Head Chef apps.',showMe:{tab:'more',page:'support',target:{testID:'customer-support'},hint:'Write a message, attach a picture if you like, and send it to CoverCharge. Owners only.'}},{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:'In the Managers app go to More \u203a Run the day \u203a Display settings 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. There is no wipe or unpair button on the Display itself. To switch a Display off, go to Settings \u203a Displays and choose Switch off.',showMe:{tab:'more',page:'displaysettings',target:{testID:'wipe-setting'},hint:'Sign out and wipe is in Display settings, in the Managers app only.'}}];function w(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 b({a:e,go:t,open:s,onToggle:n}){return(0,f.jsx)(i.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(o.default,{accessibilityRole:"button",onPress:n,children:(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(i.default,{style:{flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(l.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(l.T,{colour:y.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(i.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(l.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>w(e,t)})}):null]})})}function j(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function k({p:e,today:t,onChange:n,onConfirm:a,onCancel:o}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>n({...e.params,[t]:s}),x=e.action,m=e.params,w=x.params.every(e=>!e.required||void 0!==m[e.name]&&''!==m[e.name]);return(0,f.jsxs)(i.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?y.colours.red:y.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':y.colours.okBg},children:[(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[x.risk]}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:x.title})]}),x.form&&'add_walkin'===x.id?(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Covers",value:void 0===m.covers?'':String(m.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Table (optional)",value:void 0===m.table?'':String(m.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,x.form&&'add_rota_shift'===x.id?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{size:12,children:"Who"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(l.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:m.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1.3},children:(0,f.jsx)(l.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(m.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Start (24h)",value:String(m.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"End (24h)",value:String(m.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(l.T,{children:w?x.preview(m,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(l.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(l.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(l.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!w,onPress:a,style:{flex:1}}),(0,f.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:o,style:{flex:1}})]})]})}},1530,[812,1033,779,17,385,85,777,876,1481,1531,1532,1533,804,1057,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.','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:'guest-change-link',kind:'faq',topic:'Bookings',title:'Can guests change or cancel their own booking?',keywords:['change','cancel','link','email','guest','move','booking'],body:'Yes. The confirmation email has a "Change or cancel your booking" link for that one booking, with "Or call us on (your number) and quote your booking details." underneath. Guests can change the date, time or party size within your online booking rules, or cancel after confirming. Bookings with a deposit say "please call us" instead. Takeaway orders can\u2019t be changed or cancelled by the guest, and their email has no link. You see every change on the Display and in Managers, marked as changed by the guest. The link stops working at the booking time.'},{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:'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 takings \xf7 Covers, by day and by week. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). 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.'},{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.'}],o=t=>a.find(a=>a.id===t)},1531,[]); +__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}},1532,[]); +__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}},1533,[1534,1100,843,1535,1536,876,858,998,1481,1531,1532,1538,1537,1540,1541,996,997]); +__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))}}]},1534,[1064,1063,1023]); +__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.`)}}]},1535,[896,1100,820,843,1121,1098,1115,922,858,816,998,895,897,1010,876,1067,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]),n=_r(_d[3]),r=_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)=>r.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(),n=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(n){const e=Number(/\d/.test(n[1])?n[1]:n[2]),a=L.indexOf(/\d/.test(n[1])?n[2]:n[1]);let r=Number(t.slice(0,4));return`${r}-${A(a+1)}-${A(e)}`e.active)){const n=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),r=Math.min(...n.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));r<1/0&&a.push({s:e,at:r})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>r.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(),n=U(e);if(!n.length)return;const r=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(r)return n.find(e=>e.number===Number(r[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=n.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===n.length?n[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const r=a.useStore.getState(),i=r.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=n.useFloor.getState(),c=d.plans[e]??(0,n.seedPlan)(e),h=r.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,r.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 n=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return n?`Seat ${Y(a)}, at table ${n}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const r=z(a.rid,e.who);if(!r)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,r.partySize);return i?(await t.repo.waitlist.setStatus(r.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,r.partySize,i,`From waitlist #${r.number}`),(0,n.tablesOf)(i).forEach(e=>n.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${r.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=r.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),n=j(String(t??''),e.today);return n?a.find(e=>e.date===n):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(),n=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(n){const e=j(n[1],t),a=j(n[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!n||e.kind===n)),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 ne(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),n=new Date(a+'T00:00:00').getTime(),r=n+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=n&&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>=n&&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)()),n=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),r=(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=>r.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),n):[];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 n;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(n?.s??0)&&(n={m:t,s:e})}return n?.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 n=z(a.rid,e.who);return n?(await t.repo.waitlist.setStatus(n.id,'removed'),`Done: number ${n.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,r)=>{const i=z(r.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===r.rid);return n.useFloor.getState().logSms(r.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?r.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(r.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),n=E(e.with);return n&&n.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(n.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),n=E(e.with);return a&&t.whoId?n&&n.id!==t.whoId?(r.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:n.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(n.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)())),n=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:n&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(n[1])?n[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=r.useOwner.getState().shifts.find(e=>e.id===t.shiftId),n=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${n}\u2019s swap with ${i}`:t.toId?`${i} covering ${n}`:`${n}\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 ${n}\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=r.useOwner.getState(),n=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)}${n?` (${M[n.day]} ${R(n.start)}\u2013${R(n.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 n=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: ${n.n} checks, ${n.bad} out of range${n.bad?`, ${n.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:n}=ne(t.today,t),r=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(r)return`This week is already signed off by ${r.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${n.entries} checks, ${n.outOfRange} out of range, ${n.actions} with an action, diary signed ${n.daysSigned} of 7 days.`;return n.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:n}=ne(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':n.actions!0),note:'Signed by voice: yes to all.',summary:n}),'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),n=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${n}; 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)),n='Near miss'===a.category,r=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(r)}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??'')||(n?'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:n,rem:r}=se(t,e.task);return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?`${_(n.text)} is already ticked today.`:`Tick off today\u2019s task ${_(n.text)}?`:r?`Mark the reminder ${_(r.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:n,rem:r}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,n.id,a,i),`Done: ${_(n.text)} ticked.`):r?(c.useReminders.getState().markDone({rid:t.rid,reminderId:r.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),r=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=n?.sections.find(e=>r.includes(e.toLowerCase())||r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=String(e.section??n?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${r} 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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(r)||r<=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??n?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:r,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 n=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 n?{dish:n[1],field:'description',value:n[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 n=de(t.rid,e.dish),r=String(e.value??'').trim();return n?r.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(n.id,'name'===e.field?{name:r}:{description:r}),'name'===e.field?`Done: renamed to ${r}.`:`Done: description of ${n.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 n=(0,$.findCard)(t.rid,a.dish);return n?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${n.dish}\u2019s recipe card?${n.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)),n=a&&(0,$.findCard)(t.rid,a.dish);return a&&n?(await(0,y.recipeCards)().update(n.id,{ingredients:[...n.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 ${n.dish}.${n.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,n=String(e.step??'').trim();return!a||n.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,n]},{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],n=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),r=/\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:r,reason:n?.[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 n=e.action??'in',r=(0,g.managerClockAction)(n,{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 r.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[n]} at ${D()}.${r.warn?' '+r.warn:''}`:'Nothing changed: '+r.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 n=h.useCashUp.getState(),r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,r?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(n.tips.filter(e=>e.rid===t.rid),n.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: 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 n='yesterday'===e.day?(0,l.ymdOf)(a):e.day,r=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!n||e.date===n)).sort((e,t)=>t.date.localeCompare(e.date)),i=r[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: takings ${fe((0,p.tillTakingsOf)(i.vals))} (card + cash \u2212 card tips), tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:n?`There\u2019s no cash-up for ${(0,$.niceDay)(n)}.`:'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 r='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,n.tablesOf)(a).forEach(e=>n.useFloor.getState().setLive(t.rid,e,{note:r||void 0})),r?`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 n=(0,$.appNow)();return r.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(n)} ${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',n=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),r=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:n?.[1]?.trim(),time:r?(0,$.hm)(r[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??''),n=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(n)}, ${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(),n=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(n))return'Nothing changed: I need the wording and a time like 21:00.';const r=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:r,time:n,audience:e.audience??'all'}),'Done: reminder added.'}}]},1536,[820,858,816,998,876,1003,1014,1015,927,926,1008,839,1034,1035,1036,1004,1067,867,1076,995,854,1537,1535]); +__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.'}}]},1537,[820,891,1100,843,1140,1263,858,816,998,1003,910,846,845,1076,1077,995,1004,851,1538,1539]); +__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)}))},1538,[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)}))},1539,[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)])},1540,[816,876,910,851,1537,1017,1071]); +__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))'},1541,[]); +__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,u.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:u.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:u.VOICE_ROLE_LABEL[s],value:(0,u.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,h.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:p}=(0,f.useCtx)(6e4),u=(0,r.useDrafts)(e=>e.drafts),h=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=u.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),D='owner'===p||'manager'===p,C=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:r.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&&D?(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'})}),C(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${C(e).name} ordering`,onPress:()=>{t.default.openURL(C(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:"Drafts saved earlier (bookings, supplier shopping lists, offers, events, specials, messages and payments) wait 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."}),D?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:()=>{h(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,p.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,p.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. 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]),r=_r(_d[6]),l=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),h=_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'}}},1542,[17,362,85,777,804,1477,1538,1489,1539,1543,1217,1544,1057,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return s}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(f(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(f(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),s=(e,n,t)=>!1!==e[n]?.[t],f=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1543,[824,831,834]); +__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])},1544,[17,85,777,804,1545,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.'},1545,[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}},1546,[17,779,85,777,845,1260,1547,1548,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'},1547,[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()})},1548,[899,1547,1263]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:l,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,o.useCashUp)(e=>e.cashUps),k=(0,o.useCashSettings)(e),w=(0,d.useNightlyPrefs)(s=>s.email[e]??!1),T=(0,d.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(s=>s.rid===e&&s.on).map(e=>e.name),[N,U]=(0,s.useState)((0,u.addDaysYmd)(v,-1)),P=(0,u.cashFieldsForRecord)(k.cashFields,(0,u.cashUpRecordFor)(e,l.settings.cashUpRecord)),R=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:P,soldOut:C}),_='anchorage'!==e&&w,D=[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:D.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:()=>U(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:R.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(R.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(R.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(R.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:R.takings}),(0,j.jsx)(x,{label:"Tips",value:R.tips}),(0,j.jsx)(x,{label:"Takings last week",value:R.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:R.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:R.soldOut.length?R.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),R.cashUp.length?R.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:_,onChange:s=>T(e,s)}):null]})};var e,s=_r(_d[0]),l=_r(_d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),d=_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:s})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${s}`,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:s})]})},1549,[17,85,777,858,1008,1550,891,839,1551,1020,804,1057,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}))},1550,[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.tillTakingsOf)(k.vals):null,N=(0,l.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:s(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(y),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(O?(0,t.tillTakingsOf)(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]),l=r(d[2]);const s=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?s(t):String(t);function u(t,l,u){const c=[];for(const f of l){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const l=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==l?'Not entered':s(l)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!l.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const l=(0,n.expectedCashInDrawer)(t);null!=l&&c.push({label:'Expected cash in the drawer',value:s(l)})}return c}},1551,[839,1009,1469]); +__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.SupportChatPage=function(){const{r:e,me:f,meId:x}=(0,h.useCtx)(6e4),[j,v]=(0,s.useState)(''),[C,I]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[R,D]=(0,s.useState)('idle'),[L,P]=(0,s.useState)(''),[k,B]=(0,s.useState)(''),[_,T]=(0,s.useState)('');(0,s.useEffect)(()=>{(0,p.signedInEmail)().then(B)},[]);const E=async e=>{T('');try{const t=await(0,c.capturePlatingPhoto)(e);t&&(I(t),D(e=>'sent'===e?'idle':e))}catch(e){T(e instanceof Error?e.message:'Could not add that picture.')}},H=async()=>{const t=j.trim();if(!t||w)return;S(!0),P(''),D('idle');const s=await(0,p.writeSupportRequest)({venueName:e.name,body:t,fromName:f.replace(' (example)',''),fromEmail:k,staffRef:x||'',appVersion:u.APP_VERSION,photoDataUrl:C?.dataUrl??null});if(S(!1),s.ok)return v(''),I(null),D('sent'),void P(b);D('error'),P(s.message)};return(0,y.jsxs)(l.default,{testID:"customer-support",style:{gap:12,alignItems:'center',width:'100%',paddingBottom:8},children:[(0,y.jsx)(o.T,{center:!0,weight:"bold",colour:n.colours.gold,accessibilityRole:"header",children:"Customer support"}),(0,y.jsx)(o.Muted,{center:!0,children:"Send a message to CoverCharge. You can attach one picture, such as a photo or a screenshot. We'll reply by email."}),'sent'===R?(0,y.jsx)(l.default,{testID:"support-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:b,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"success",title:b})}):null,'error'===R?(0,y.jsx)(l.default,{testID:"support-error",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:L,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"danger",title:L})}):null,(0,y.jsx)(t.TextInput,{testID:"support-message",accessibilityLabel:"Your message to CoverCharge",value:j,onChangeText:e=>{v(e),'sent'===R&&D('idle')},placeholder:"Write your message",placeholderTextColor:n.colours.muted,multiline:!0,style:{width:'100%',minHeight:120,borderWidth:1,borderColor:n.colours.border,borderRadius:12,padding:12,color:n.colours.text,textAlign:'center'}}),C?(0,y.jsxs)(l.default,{testID:"support-photo-preview",style:{alignItems:'center',width:'100%',gap:8},children:[(0,y.jsx)(r.default,{source:{uri:C.dataUrl},style:{width:240,height:180,borderRadius:12,backgroundColor:n.colours.surface2},accessibilityLabel:"Attached picture preview"}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Remove picture",accessibilityLabel:"Remove the attached picture",testID:"support-photo-remove",onPress:()=>I(null),style:{minHeight:48}})]}):(0,y.jsxs)(l.default,{style:{width:'100%',gap:8,alignItems:'center'},children:[(0,y.jsx)(o.Button,{kind:"secondary",label:"Take a photo",accessibilityLabel:"Take a photo to attach",testID:"support-photo-camera",onPress:()=>{E('camera')},style:{minHeight:48,width:'100%'}}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a picture or screenshot from your gallery",testID:"support-photo-gallery",onPress:()=>{E('library')},style:{minHeight:48,width:'100%'}})]}),_?(0,y.jsx)(o.Muted,{center:!0,testID:"support-photo-error",children:_}):null,(0,y.jsx)(o.Button,{testID:"support-send",label:"Send to CoverCharge",accessibilityLabel:"Send to CoverCharge",disabled:!j.trim()||w,onPress:()=>{H()},style:{minHeight:56,width:'100%'}}),w?(0,y.jsx)(l.default,{accessibilityLiveRegion:"polite",style:{width:'100%'},children:(0,y.jsx)(o.Muted,{center:!0,testID:"support-sending",children:"Sending\u2026"})}):null]})};var t=_r(d[0]),s=_r(d[1]),r=e(_r(d[2])),l=e(_r(d[3])),o=_r(d[4]),n=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),y=_r(d[10]);const b="Sent. We'll reply by email."},1552,[812,17,319,85,777,804,1082,978,1553,1057,8]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPPORT_BUCKET",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SUPPORT_SEND_FAILED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SUPPORT_SIGN_IN",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SUPPORT_NO_EMAIL",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SUPPORT_PHOTO_FAILED",{enumerable:!0,get:function(){return l}}),e.writeSupportMessage=async function(o){if(!t.RELEASE.supportSync)return{ok:!1,message:n.SUPPORT_NOT_SENT};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:n.SUPPORT_NOT_SENT};const c=u.useSync.getState().venueId;if(!c)return{ok:!1,message:`${n.SUPPORT_NOT_SENT} Sign in and try again.`};try{const t=(0,i.getSupabase)(),{error:s}=await t.from('support_messages').insert({venue_id:c,body:o.text,from_name:o.from,staff_ref:o.staffRef||null});return s?{ok:!1,message:n.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:n.SUPPORT_NOT_SENT}}},e.writeSupportRequest=async function(t){if('undefined'!=typeof globalThis&&globalThis.__CC_SUPPORT_FAKE_SEND)return{ok:!0,id:'preview-test',emailed:!0};const n=t.body.trim().slice(0,4e3),S=t.fromName.trim().slice(0,80),y=t.fromEmail.trim().slice(0,254),P=t.venueName.trim().slice(0,120);if(!n||!S||!P)return{ok:!1,message:f};if(!y||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y))return{ok:!1,message:m};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:p};const b=u.useSync.getState().venueId;if(!b)return{ok:!1,message:p};const T=globalThis.crypto?.randomUUID?.()??`00000000-0000-4000-8000-${Date.now().toString(16).padStart(12,'0')}`,O=(0,i.getSupabase)();let h=null;if(t.photoDataUrl)try{const n=_(t.photoDataUrl);h=`${b}/${T}.jpg`;const{error:o}=await O.storage.from(c).upload(h,n,{contentType:'image/jpeg',upsert:!1});if(o)return{ok:!1,message:l}}catch{return{ok:!1,message:l}}const E={id:T,venue_id:b,venue_name:P,body:n,from_name:S,from_email:y,staff_ref:t.staffRef||null,app_version:(t.appVersion||o.APP_VERSION).slice(0,40),photo_path:h},{error:N}=await O.from('support_requests').insert(E);if(N)return{ok:!1,message:f};let U=!1;try{const t=await O.functions.invoke('send-support-email',{body:{request_id:T}}),n=t.data;U=!t.error&&!!n?.sent}catch{U=!1}return{ok:!0,id:T,emailed:U}},e.signedInEmail=async function(){if(!(0,s.isSupabaseConfigured)())return'';try{const{data:t}=await(0,i.getSupabase)().auth.getUser();return(t.user?.email??'').trim()}catch{return''}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),i=r(d[4]),u=r(d[5]);const c='support-photos',f='Could not send. Check your connection and try again.',p='Could not send. Sign in and try again.',m='Your sign-in has no email. Sign in again and try again.',l='Could not attach the picture. Try a smaller photo, or send without a picture.';function _(t){const n=/^data:([^;]+);base64,(.+)$/.exec(t);if(!n)throw new Error('bad picture');const o=atob(n[2]),s=new Uint8Array(o.length);for(let t=0;t{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{}}},1554,[17,264,219,85,777,812,804,899,1430,1188,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+'},1555,[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 ']]},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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:te,height:se}=(0,a.default)(),[oe,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(!1),[le,ae]=(0,t.useState)(!1),[de,ce]=(0,t.useState)(''),[ue,ge]=(0,t.useState)(!1),[he,pe]=(0,t.useState)(!1),[be,fe]=(0,t.useState)(!1),[me,xe]=(0,t.useState)(!1),ke=(0,t.useRef)(null),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(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,M.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const Ce=(0,K.useTakingsAllowed)(s),ve=(0,t.useCallback)(e=>{const t=(0,A.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),De=(0,t.useMemo)(()=>(0,V.buttonsFor)({takings:Ce,pageOk:ve}),[Ce,ve]),Ie=oe?(0,V.tabsFor)(oe.btn,{takings:Ce,pageOk:ve}):[],Se=(0,t.useCallback)((e,t)=>{const s=(0,V.tabsFor)(e,{takings:Ce,pageOk:ve});s.length&&(ie(!1),ae(!1),ce(''),ne({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[Ce,ve]),Te=De.find(e=>'settings'===e.id),Re=(0,t.useCallback)(e=>{const t=De.find(t=>t.pages.some(t=>t.id===e));t?Se(t,e):Te&&ve(e)&&(ie(!1),ae(!1),ce(''),ne({btn:Te,tab:'@desk-settings',page:e}))},[De,Se,Te,ve]),Oe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Re(t);else{if('bookings'===e){const e=De.find(e=>'bookings'===e.id);return void(e&&Se(e,'@bookings'))}if('chat'===e){const e=De.find(e=>'chat'===e.id);return void(e&&Se(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Te&&Se(Te):ne(t=>({btn:t?.btn??De[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else ne(null)},[De,Se,Re,Te]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Oe}),()=>T.useVoiceNav.setState({go:null})),[Oe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Oe('bookings'):'chat'===e?Oe('chat'):Oe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Pe=!oe||De.some(e=>e.id===oe.btn.id)&&Ie.some(e=>e.id===oe.tab)&&(!oe.page||ve(oe.page));(0,t.useEffect)(()=>{if(!Pe){const e=setTimeout(()=>ne(null),0);return()=>clearTimeout(e)}},[Pe]);const Le=oe?.page?(0,A.pageFor)(oe.page):void 0,We=oe?(0,_.deskCopy)(Le?.title??oe.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${We} \xb7 The Anchorage \xb7 CoverCharge for desktop`),we.current?.scrollTo?.({y:0,animated:!1}),oe){const e=setTimeout(()=>Y(je.current),80);return()=>clearTimeout(e)}},[We,oe?.tab,oe?.page]),(0,t.useEffect)(()=>{if(le){const e=setTimeout(()=>ke.current?.focus?.(),100);return()=>clearTimeout(e)}},[le]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=q(e.target),s=(0,_.commandKey)(e,t);if('escape'===s){if(le||ue||he||be)return e.preventDefault(),ae(!1),ge(!1),pe(!1),void fe(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return re?(e.preventDefault(),void ie(!1)):void(oe&&(e.preventDefault(),ne(null)))}if(le||ue||he||be||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),ie(!1),void ae(!0);if('help'===s)return e.preventDefault(),void ge(!0);if('filter'===s&&ye.current&&oe)return e.preventDefault(),void ye.current?.focus?.();const o=t?null:(0,_.shortcutIndex)(e);null!=o&&De[o]&&(e.preventDefault(),Se(De[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[le,ue,he,be,re,oe,De,Se]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Oe,globalThis.__deskOpen=(e,t)=>{const s=De.find(t=>t.id===e);s&&Se(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Oe,De,Se]);const Be=(0,t.useMemo)(()=>{const e=de.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De.flatMap(e=>(0,V.tabsFor)(e,{takings:Ce,pageOk:ve}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Se(e,t.id)}))),o=new Set(De.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...A.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,_.deskCopy)(e.title),sub:(0,_.deskCopy)(e.sub??''),run:()=>Re(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[de,De,s,Ce,ve,Se,Re]),He=(0,N.ddmmyyyy)(o),Me=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),Ee=b?(0,B.authorityRole)(b):s,$e=(b?.name??h).replace(' (example)',''),ze='owner'===Ee?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Ae=e=>(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Fe=e=>{const t=(0,A.pageFor)(e);return!t||t.can&&!t.can(s)?(0,X.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,X.jsx)(t.C,{go:Oe})})};return(0,X.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,X.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>oe?Y(je.current):ie(!0),children:(0,X.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:oe?'Skip to main content':'Open the owner tools menu'})}),(0,X.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,X.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:te,headerExtra:(0,X.jsx)(J,{open:re,onPress:()=>ie(!0)}),subHeader:(0,X.jsx)(Q,{name:$e,access:ze,day:He,at:Me})}),oe&&Pe?(0,X.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,X.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,X.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,X.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:oe.page?'Back to all settings':`Close ${oe.btn.label}, back to the floor plan`,onPress:()=>oe.page?ne({...oe,page:null}):ne(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,X.jsx)(f.T,{weight:"semibold",center:!0,children:oe.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,X.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,X.jsx)(l.default,{ref:je,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,X.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:We})}),(0,X.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,_.deskCopy)(Le?.sub??oe.btn.hint)})]}),(0,X.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,X.jsx)(J,{testID:"desk-menu-button-page",open:re,onPress:()=>ie(!0)})})]}),Ie.length>1&&!oe.page?(0,X.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Ie.map(e=>{const t=e.id===oe.tab;return(0,X.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>ne({btn:oe.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?Z:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,X.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,X.jsx)(i.default,{ref:we,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(!oe||!Pe)return null;if(oe.page)return Fe(oe.page);switch(oe.tab){case'@desk-bookings':return(0,X.jsx)(K.DesktopBookings,{filterRef:ye});case'@desk-hours':return(0,X.jsx)(K.DesktopHours,{go:Oe,filterRef:ye});case'@desk-takings':return Ce?(0,X.jsx)(K.DesktopTakings,{go:Oe}):(0,X.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,X.jsx)(K.DesktopSettings,{open:e=>ne(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,X.jsx)(G.DeskPermissions,{});case'@desk-leavers':return(0,X.jsx)(G.DeskLeavers,{});case'@desk-temps':return Ae((0,X.jsx)(G.DeskTemps,{}));case'@desk-bookinghistory':return Ae((0,X.jsx)(G.DeskCoversHistory,{}));case'@bookings':return(0,X.jsx)(H.Bookings,{go:Oe});case'@chat':return(0,X.jsx)(M.Chat,{go:Oe});case'@noshows':return Ae((0,X.jsx)(W.NoShows,{go:Oe}));case'@orders':return(0,X.jsx)($.Orders,{});case'@forecast':return(0,X.jsx)(E.Forecasts,{go:Oe});default:return Fe(oe.tab)}})()})]}):null]}),(0,X.jsx)(ee,{visible:re,buttons:De,current:oe?.btn.id,W:te,H:se,onClose:()=>ie(!1),onPick:e=>Se(e),onFind:()=>{ie(!1),ae(!0)},onKeys:()=>{ie(!1),ge(!0)},onInstall:()=>{ie(!1),pe(!0)},onSignOut:()=>{ie(!1),fe(!0)}}),le?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ae(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,X.jsx)(p.TextInput,{ref:ke,value:de,onChangeText:ce,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,X.jsx)(l.default,{'aria-live':'polite',children:(0,X.jsxs)(f.Muted,{center:!0,children:[Be.length," pages"]})}),Be.slice(0,60).map(e=>(0,X.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,X.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,X.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ue?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ge(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,_.SHORTCUTS)((0,F.isMac)()).map(([e,t])=>(0,X.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,X.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,X.jsx)(f.T,{center:!0,children:t})]},e)),(0,X.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,be?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>fe(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,X.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,X.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,X.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>fe(!1),testID:"desk-signout-cancel"}),(0,X.jsx)(f.Button,{label:me?'Signing out\u2026':'Sign out',disabled:me,onPress:async()=>{xe(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,he?(0,X.jsx)(f.Sheet,{visible:!0,onClose:()=>pe(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,X.jsx)(U.DesktopInstallPage,{})}):null,(0,X.jsx)(k.SeatAllergenReminder,{rid:e}),(0,X.jsx)(x.PrintHost,{rid:e}),(0,X.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Oe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,X.jsx)(z.OnboardingHost,{go:Oe}),(0,X.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]);r(d[37]);var F=r(d[38]),_=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]);const q=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Y=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},Z='rgba(201,162,74,0.14)';function J({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,X.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,X.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,X.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,X.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function Q({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,X.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,X.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,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function ee({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,V.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(()=>Y(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,F.isMac)();return(0,X.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,X.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,X.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,X.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,X.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,X.jsx)(l.default,{style:{width:56}}),(0,X.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,X.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,X.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,X.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,V.deskShortcut)(t,B);return(0,X.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,X.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:Z,alignItems:'center',justifyContent:'center'},children:(0,X.jsx)(G.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,X.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,X.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,X.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1558,[17,266,347,219,385,278,85,409,19,780,812,779,777,1230,1394,1087,1481,1086,1084,1232,1245,891,876,1032,1489,880,899,804,1340,1559,1057,1419,1161,1483,1485,1474,1458,1487,1555,1557,1565,1566,1567,1570,1573,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))}},1559,[17,266,347,219,385,278,85,409,780,779,1340,1458,1487,1419,1161,1485,1483,1057,1026,777,858,876,863,899,880,804,1560,1561,1562,1563,1564,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1560,[]); +__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])},1561,[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])},1562,[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])},1563,[17,385,1163,1164,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},1564,[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,b=Math.round(1.4*h),k=Math.max(48,Math.min(72,c-2*b-14,l-34));return{panelW:n,colW:l,per:c,circle:k,label:h,lineH:b,icon:Math.round(.44*k),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}],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'},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','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}`},1565,[1560]); +__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)},1566,[]); +__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,f.useOwner)(e=>e.staff),x=(0,f.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)),T=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=T.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,f.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,D.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,m.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,D.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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,D.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,D.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,f]=(0,t.useState)('next7'),[m,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[T,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,D.bookingColumns)(T),[T]),E=(0,t.useMemo)(()=>(0,D.sortRows)((0,D.filterRows)((0,D.bookingsBetween)(r,W,L,m),z,x),z.find(e=>e.key===$),M),[r,W,L,m,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:()=>f(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:m===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:T?'Hide phone numbers':'Show phone numbers',selected:T,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,D.csvName)('bookings',W,L),(0,D.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,D.ddmmyyyy)(W)}${L!==W?` to ${(0,D.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,D.ddmmyyyy)(W)} to ${(0,D.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,D.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${D.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,D.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",D.STATUS_WORD[G.status]??G.status]}),G.phone&&T?(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,f.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,m]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,T]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,f.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,D.ukTime)(e.in),outT:(0,D.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,D.sortRows)((0,D.filterRows)(O.filter(e=>'all'===p||e.status===p),D.HOURS_COLUMNS,y),D.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:m,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,D.csvName)('hours',R,M),(0,D.toCsv)(N,D.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,D.hm)((0,D.totalPaid)(N))} paid \xb7 ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`,cols:D.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(T(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,D.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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:T.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...T.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!T.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,T.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,T.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,T.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]),f=_r(_d[13]),m=_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]),T=_r(_d[23]),D=_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 f.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]}},1567,[17,385,85,409,812,777,1072,1032,1180,1122,1091,858,1008,876,1055,839,889,899,804,1419,1057,1458,1568,1557,1566,1569,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},1568,[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)}.`}},1569,[17,85,780,777,804,1568,1566,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}]},1570,[17,264,385,85,780,777,858,876,1571,915,1215,1465,804,1561,1057,1568,1572,1566,1569,1567,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)}))},1571,[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)},1572,[915]); +__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))})]})}},1573,[17,85,777,804,1574,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)},1574,[]); +__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:h,today:O,now:I,meId:N,me:X}=(0,A.useCtx)(3e4);(0,x.useTipsPosted)(e,O);const Z=(0,A.useSignedIn)();(0,m.useSoldOutLink)(!0,(Z?.name??X).replace(' (example)',''));const[q,J]=(0,s.useState)({kind:'tab',tab:'home'}),[Q,Y]=(0,s.useState)(''),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,A.ensureAttendance)(O,I),(0,D.ensureChat)(I)},[O]),globalThis.__ccNow=I.getTime();const te=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=V[t];return void J(e?{kind:'edit',id:e}:{kind:'page',id:t})}J('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:te}),()=>C.useVoiceNav.setState({go:null})),[te]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=te,globalThis.__deskGo=e=>J(e))},[te]),(0,v.useAlertWatcher)(e,{nag:'staff'!==h}),(0,w.useScheduledNotices)({rid:e,staffId:Z?.id??'',name:X,onOpen:e=>'bookings'===e?te('bookings'):'chat'===e?te('chat'):te('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==h&&!!Z});const ae=(0,s.useMemo)(()=>[...$,...F].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 ee.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=ae[Number(e.key)-1];return void(t&&(e.preventDefault(),J(t)))}if('z'===t&&!U(e.target)){const t=(0,z.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!U(e.target)){const t=(0,z.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae]);const se=B.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(h))&&!V[e.id]),ne=(0,s.useMemo)(()=>{const e=Q.trim().toLowerCase(),t={};return se.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[se,Q]),oe=$.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(h)),re=p.CAN.forecasts(h)?F:F.filter(e=>'rota'===e.s.id),ie='page'===q.kind?(0,B.pageFor)(q.id):void 0,le='tab'===q.kind?$.find(e=>K(e.s,q))?.label:'edit'===q.kind?F.find(e=>K(e.s,q))?.label:ie?.title,de='tab'===q.kind?$.find(e=>K(e.s,q))?.tip:'page'===q.kind?`${ie?.sub??''}. Press ${(0,_.CMD)()}K to jump to any page.`:'',ue=({label:e,s:t,n:a})=>{const s=K(t,q);return(0,W.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>J(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,W.jsx)(f.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,W.jsxs)(f.T,{size:11,colour:S.colours.muted,children:[(0,_.CMD)(),a]}):null]})},ce=({t:e})=>(0,W.jsx)(f.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),be='owner'===h?'OWNER':'manager'===h?'MANAGER':'STAFF';return(0,W.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,W.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,W.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(f.Row,{gap:10,children:[(0,W.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(u.VenueName,{name:c.name}),(0,W.jsx)(f.Row,{gap:6,children:(0,W.jsx)(l.AppBadge,{label:be})})]})]}),(0,W.jsx)(u.PoweredBy,{}),(0,W.jsx)(a.TextInput,{ref:ee,testID:"side-filter",value:Q,onChangeText:Y,placeholder:`Find a page (${(0,_.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[f.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,W.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Q?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{t:"Run the day"}),oe.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:t+1},e.label)),(0,W.jsx)(ce,{t:"Drag-and-drop editors"}),re.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:oe.length+t+1},e.label))]}),Object.entries(ne).map(([e,t])=>(0,W.jsxs)(r.default,{children:[(0,W.jsx)(ce,{t:e}),t.map(e=>(0,W.jsx)(ue,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,W.jsxs)(r.default,{style:{flex:1},children:[(0,W.jsx)(r.default,{testID:"desk-title",children:(0,W.jsx)(f.T,{size:24,weight:"bold",children:le??''})}),(0,W.jsxs)(f.Muted,{size:12,children:[Z?`Signed in as ${Z.name} \xb7 ${p.ROLE_LABEL[h]}`:`Preview \xb7 ${p.ROLE_LABEL[h]}`," \xb7 ",c.name]})]})}),(0,W.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[de?(0,W.jsx)(H.Tip,{children:de}):null,'edit'===q.kind?(0,W.jsx)(G,{id:q.id,rid:e,me:X,role:'owner'===h?'owner':'manager',today:O,venue:c.name}):(0,W.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===q.kind&&'home'===q.tab?(0,W.jsx)(L.Dashboard,{go:te}):null,'tab'===q.kind&&'orders'===q.tab?(0,W.jsx)(P.Orders,{}):null,'tab'===q.kind&&'bookings'===q.tab?(0,W.jsx)(E.Bookings,{}):null,'tab'===q.kind&&'forecast'===q.tab?(0,W.jsx)(R.Forecasts,{go:te}):null,'tab'===q.kind&&'chat'===q.tab?(0,W.jsx)(D.Chat,{go:te}):null,ie?(0,W.jsx)(ie.C,{go:te}):'page'===q.kind?(0,W.jsx)(f.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,W.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==h?(0,W.jsx)(g.PrintHost,{rid:e}):null,'staff'!==h?(0,W.jsx)(b.AlertHost,{variant:"managers",rid:e,me:X,onOpen:e=>te('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,W.jsx)(M.OnboardingHost,{go:te}),(0,W.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]),f=_r(d[12]),h=_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]);_r(d[33]);var O=_r(d[34]),_=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]);const $=[{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.'}],F=[{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:''}],V={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},K=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),U=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function G({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,h.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,W.jsx)(I.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,W.jsx)(N.RotaEditor,{today:o}):'brand'===e?(0,W.jsx)(O.BrandEditor,{rid:t}):(0,W.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,W.jsxs)(H.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,_.CMD)(),"Z undoes, then Save."]}),g?(0,W.jsx)(f.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,W.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,W.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{h.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)})]})}},1575,[813,812,17,385,278,85,19,1363,857,1366,1230,1394,777,998,876,891,1032,1481,1087,1086,1084,1489,1232,880,804,1419,1161,1057,1432,1483,1474,1485,1458,1487,1576,1555,1578,1580,1582,1579,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])},1576,[17,278,85,1502,857,777,876,814,1459,804,1577,1578,1579,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)})},1577,[]); +__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},1578,[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})},1579,[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."})]})]})}},1580,[812,17,85,777,860,816,891,893,894,845,867,1153,804,1577,1578,1579,1581,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])},1581,[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)}`},1582,[17,85,777,876,1060,804,1577,1578,1579,1051,1581,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]})}},1583,[13,17,856,1584,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)','')}})}},1584,[1459,1585,813,912,1072,1511,1209,1210,1028,1025,1026,1512,1546,1514,1153,891,978,1586,975,880,1031,1032,1495,914,1008,915,17,1155,1241,1245,1203,356,385,278,85,409,19,777,857,876,804,1161,1419,1066,1084,1086,1081,1027,1010,1057,1505,1500,1527,1587,1427,920,219,1246,1182,1188,1457,1202,1199,1482,1185,878,1212,1213,884,776,899,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']]},1585,[17,85,777,1057,899,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}},1586,[219,976]); +__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)','')},1587,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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]})}},1588,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1589,[1452,899,778,1413,1590,995,13,1617,479,17,368,319,219,24,85,805,857,1065,856,1619,19,858,998,876,804,1427,920,988,1620,1621,1028,1104,880,1008,914,1623,1383,8,1624,1625,1626,1627]); +__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])},1590,[1591,1614,1616]); +__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)}}},1591,[198,1592,1595,1609,1610,1611,1612,1613]); +__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}},1592,[198,1593]); +__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}},1593,[1594]); +__d(function(g,r,i,a,m,e,d){},1594,[]); +__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)}},1595,[1596,198,1592,1609,1610]); +__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]}})})},1596,[1597,1598,1608]); +__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()}})}},1597,[1598,1602,1607]); +__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}}},1598,[198,355,1599,1603,1604,1605,1606,1602,1607]); +__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}},1599,[198,1600,322,263,1601,1602]); +__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])},1600,[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}}},1601,[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},1602,[]); +__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}},1603,[]); +__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}},1604,[]); +__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])},1605,[1603]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1606,[]); +__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},1607,[355,1601]); +__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])},1608,[17,1598]); +__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}},1609,[1596,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])},1610,[1596,1609]); +__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}},1611,[1592]); +__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])},1612,[198,1592,1595,1593]); +__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})({})},1613,[]); +__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]))},1614,[198,37,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 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')},1615,[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]}},1616,[17,1591]); +__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]}})})},1617,[1618]); +__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(){}},1618,[]); +__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]})}},1619,[17,24,85,409,777,857,920,899,880,805,804,1560,1562,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()})},1620,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1621,[813,779,17,974,385,85,856,899,976,804,777,1352,971,880,1622,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1622,[17,1460,385,85,899,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1623,[]); +__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"},1624,[]); +__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"},1625,[]); +__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"},1626,[]); +__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"},1627,[]); +__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]})}},1628,[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},1629,[1630]); +__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},1630,[8,1631,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}))}}},1631,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1632,[]); +__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})}}},1633,[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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 2319eda39b78ac53ff4e28b07e2613964b5de223..94703536f322a982761326739adea16c9e711efb 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 62db7514038b1171741041f707ea3ff7d64696a5..a920caecf3aa14eb341d02c68c6b2e204b9a9d85 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-3f66d04337"; +const V = "cc-owner-f627bfe3b5"; 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=3f66d043372ffa5e6a0e35543f30013bd47d49fa66b78b2aa170d3af2efe24a1"]; +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=f627bfe3b5d85dd756af9ed75365984a8f675f7eb6aa40ce33bb4bb17c91e61d"]; // 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 c81ab7b4734f8c9d9af48d45cf024729e9305145..4474c9bc99783a9c22907957f12d6d028adb213f 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 c2811e5b9c229981cf6efddfdbd37a6a727a441a..1186a9e1581f3288dacc4f04798e77af829c4623 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,1631]); +__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,1633]); __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,1627,1630]); +__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,1629,1632]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1246,1247,1252,1254,1256,1263,1315,1316,1317,1318,1319,1320,1322,1323,1324,1325,1329,1332,1333,1334,1335,1338,1412,1413,1414,1581,1586,1587,1626]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1247,1248,1253,1255,1257,1264,1316,1317,1318,1319,1320,1321,1323,1324,1325,1326,1330,1333,1334,1335,1336,1339,1414,1415,1416,1583,1588,1589,1628]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1181,1184,1187,1198,1201,1206,1208,1209,1028,884,920,1211,1156,1212,1224,1229,1238,1231,1154,1240,1244,1202,858,1152,899,1245,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1182,1185,1188,1199,1202,1207,1209,1210,1028,884,920,1212,1157,1213,1225,1230,1239,1232,1155,1241,1245,1203,858,1153,899,1246,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,496 +1222,498 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1156,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1174,[812,17,385,85,777,779,905,858,847,906,907,804,889,1175,1179,1156,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1176,[1177,928,899,856,880,1178,1038]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1177,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1178,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1179,[17,85,780,777,905,858,908,804,889,1156,1180,8]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1180,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1181,[812,1182,17,385,85,409,777,876,851,863,804,1183,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1183,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1184,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1185,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1185,[17,777,858,1186,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1186,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1187,[812,1033,1182,17,1188,219,385,409,85,1190,1191,1192,777,816,876,851,1034,804,889,1198,1183,1057,1035,1193,856,1194,1199,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1188,[17,385,85,1189,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1189,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1190,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1191,[17,85,777,812,876,851,1190,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1192,[812,1190,17,385,85,777,884,876,1071,863,804,1183,1057,1193,856,1194,1191,1195,1197,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1193,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1194,[17,85,777,876,1008,1033,1064,1062,1193,804,856,1192,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1195,[1034,1196]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1196,[1034,1190]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1197,[17,85,777,812,1033,1034,1195,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1198,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1183,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1199,[1033,17,385,85,777,812,876,1196,1034,1200,1097,804,1187,1057,1051,1190,1195,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1200,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1201,[813,876,1202,1070,1182,923,924,17,975,976,219,385,278,85,777,858,1071,1203,1192,1162,1204,1059,805,1205,1140,851,863,804,1183,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1195,1197,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1202,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1203,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1204,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1205,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1206,[17,85,777,876,804,1057,1060,1204,1071,1207,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1207,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1208,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1209,[17,219,85,1057,876,1210,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1210,[]); -__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1211,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1212,[812,1213,779,1214,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1215,1218,1221,1223,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1213,[880,805,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1214,[17,1003,876,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1215,[219,1216]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1216,[1217,856]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1217,[928,903]); -__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1218,[813,1213,1033,779,812,1214,820,876,17,319,385,85,780,777,884,1003,1004,1219,804,889,1215,1220,8]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1219,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1220,[816,876,805]); -__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1221,[17,1033,362,219,85,777,876,1003,1220,1004,1222,804,889,1214,928,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1222,[1004,991]); -__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1223,[17,85,777,804,889,992,905,858,876,1033,1222,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1224,[17,1157,1158,385,85,777,910,845,911,804,889,1225,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1225,[813,17,319,378,385,278,85,1226,777,910,845,911,863,804,1019,8,1228]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1226,[901,17,1227,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1227,[880,899]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1228,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1229,[843,1028,17,219,385,85,780,858,804,777,1230,1104,1231,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1230,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1231,[1232,1233,1235,1234,1236,1018,1237]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1232,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1233,[824,805,831,834,856,1018,1234]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1234,[843,219,856,1232]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1235,[17,858,845,853,851,1233,1232]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1236,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1237,[17,1233,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1238,[17,385,85,409,858,845,804,777,1229,1104,1239,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1239,[17,85,409,858,845,1231,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1240,[17,219,385,85,864,777,804,916,1241,1242,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1241,[856,806,928,971,916,1231,1242]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1242,[824,1243,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1243,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1244,[17,856,1241]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1245,[17,385,329,85,409,804,1189,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1246,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1247,[843,1099,861,13,17,1248,917,85,841,1249,1079,1055,777,845,851,1105,863,858,899,804,1186,848,995,998,1076,1107,1250,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1248,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1249,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1250,[17,385,85,862,863,1033,1251,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1251,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1252,[900,13,17,319,85,1226,1253,777,845,851,858,867,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1253,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1254,[13,17,777,1255,858,1240,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1255,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1256,[822,13,17,1257,777,851,858,804,1258,1262,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1257,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1258,[17,85,777,851,1259,1260,1261,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1259,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1260,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1261,[928,899,1260]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1262,[831,928,971,899,880,1259]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1263,[1264,1265,805,1266,1275,1276,1277,843,13,17,219,385,85,1226,1253,777,845,851,862,858,900,804,1278,1240,856,876,1225,910,911,920,1279,1262,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1264,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1265,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1266,[17,85,777,1267,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1267,[806,1033,1268,1270,1272,17,85,812,777,804,1269,1273,1274,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1269,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1270,[1271,1269]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1271,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1272,[1269]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1273,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1274,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1275,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return C}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>P(o.settings.defaultTarget));return l?(0,f.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,f.jsx)(r.default,{testID:"margin-alert",children:(0,f.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,f.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,f.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,f.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,f.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,f.jsx)(D,{draft:g,setDraft:h,onNew:()=>h(P(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,f.jsx)(G,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,f.jsx)(V,{}):null,'settings'===c?(0,f.jsx)(W,{}):null,(0,f.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,f.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,f.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=A,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=R,_e.Items=V,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,w=c?.[e.id]??{lines:[],portions:1},P=(0,u.cardCostSummary)(w,l,o,e.price),[$,S]=(0,i.useState)(''),[D,k]=(0,i.useState)(),[M,G]=(0,i.useState)(!1),[B,V]=(0,i.useState)(w.menuPrice?(w.menuPrice/100).toFixed(2):''),[z,W]=(0,i.useState)(!1),[F,E]=(0,i.useState)(null),[U,H]=(0,i.useState)(!w.lines.length),[q,_]=(0,i.useState)(!1),[Y,X]=(0,i.useState)(null!=w.target?String(w.target):'');if(!h)return null;const K=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??w,...t}),J=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},Q=(t,s=D)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...J(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...l.lines,n]}),S(''),k(void 0),G(!1),_(!1)},Z=(e,t)=>K({lines:w.lines.map((s,i)=>i===e?{...s,...t}:s)}),ee=new Set(w.lines.map(e=>e.recipeIngId).filter(Boolean)),te=e.ingredients.filter(e=>e.name.trim()&&!ee.has(e.id)),se=te.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),ie=P.price?P.price/(1+o.vatPct/100):null,ne=l.filter(e=>!$.trim()||$.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes($.trim().toLowerCase())).slice(0,12),le=v(B),re=P.tone?T[P.tone]:x.colours.muted,ae=null!=e.price&&P.price===e.price;return(0,f.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:N},children:[(0,f.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",P.target,"% GP"]}),P.price?(0,f.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(P.price)} including VAT, ${(0,u.money)(ie)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(P.price)," inc VAT \xb7 ",(0,u.money)(ie)," ex VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[P.priceIsSuggested?'Suggested price':w.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,w.lines.length?(0,f.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:P.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,f.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?`${(0,u.money)(e.cost)}, ${(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}`:'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,f.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(a.T,{weight:"medium",children:e.name}),(0,f.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label}),i?(0,f.jsx)(a.T,{testID:"card-gp-line-rates",size:x.font.small,colour:x.colours.goldLight,children:(0,u.lineRatesText)((0,u.lineRates)(e.cost,w.portions||1,i))}):null]}),(0,f.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),U&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,f.jsx)(R,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Z(s,{unit:t})},t);return(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Z(s,{qty:C(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,f.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})]})]})})():U&&y?(0,f.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,f.jsx)(R,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>K({lines:w.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,f.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,f.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&w.lines.length?(0,f.jsx)(a.Button,{small:!0,kind:U?'primary':'secondary',testID:"gp-edit",label:U?'Done':'Change amounts or ingredients',accessibilityLabel:U?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{H(!U),G(!1)}}):null,y&&U?(0,f.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[se.length?(0,f.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${se.length} matching price${1===se.length?'':'s'}`,accessibilityLabel:`Link ${se.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??w;K({lines:[...t.lines,...se.map(({ri:e,i:t})=>({ingId:t.id,...J(t,e),recipeIngId:e.id}))]}),E(`Linked ${se.length} ingredient${1===se.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,te.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:te.slice(0,10).map(e=>(0,f.jsx)(R,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:D===e.id,onPress:()=>{k(e.id),S(e.name.split(/[,(]/)[0].trim()),G(!0)}},e.id))})]}):null,M?(0,f.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,f.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:$,onChangeText:S,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ne.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,f.jsx)(R,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>Q(e)},e.id)}),ne.length?null:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),q?(0,f.jsx)(A,{initial:$.trim(),onDone:e=>{_(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&Q(t)}}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:$.trim()?`Add a price for ${$.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${$.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>_(!0)}),(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{G(!1),k(void 0),S(''),_(!1)}})]}):(0,f.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{G(!0),k(void 0)}}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,f.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${P.target}`,value:Y,onChangeText:e=>{X(e);const t=C(e);null!=t&&t>0&&t<95?K({target:t}):e.trim()||K({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,f.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(w.portions||1),onChangeText:e=>K({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(P.perPortion),colour:x.colours.goldLight,sub:(w.portions||1)>1?`Batch ${(0,u.money)(P.batch)} \xf7 ${w.portions}`:P.missing?`${P.missing} line${1===P.missing?'':'s'} not costed`:void 0}),(0,f.jsx)(O,{testID:"gp-suggested",label:`Suggested at ${P.target}% GP`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,f.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,f.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:B,onChangeText:e=>{const t=(0,j.sanitiseMoneyTyping)(e);V(t);const s=v(t);null!=s&&s>0?K({menuPrice:s}):t.trim()||K({menuPrice:void 0})},placeholder:P.price?(P.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:le?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),P.suggested&&!le?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(P.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(P.suggested)}`,onPress:()=>{V((P.suggested/100).toFixed(2)),K({menuPrice:P.suggested})}}):null]}):null,(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-gp",label:`GP on ${P.price?(0,u.money)(P.price):'the price'}`,value:null!=P.gp?(0,u.pct)(P.gp):'\u2014',colour:re,sub:null!=P.gp?'ok'===P.tone?'On target':'amber'===P.tone?'Just under target':'Below target':void 0}),(0,f.jsx)(O,{testID:"gp-cash",label:"Cash GP per portion",value:null!=P.cashGp?(0,u.money)(P.cashGp):'\u2014',colour:re,sub:P.price?`${(0,u.money)(P.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),(()=>{const e=(0,u.foodCostTargetOf)(P.target),t=null!=P.foodCostPct?(0,u.foodCostTone)(P.foodCostPct,e):null,s=t?T[t]:x.colours.muted,i=P.price&&P.perPortion>0?(0,u.vatAwareGp)(P.perPortion,P.price,o.vatPct):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(O,{testID:"gp-food-cost-pct",label:"Food cost %",value:null!=P.foodCostPct?(0,u.pct)(P.foodCostPct):'\u2014',colour:s,sub:null!=P.foodCostPct?`Target ${e}% \xb7 ${'ok'===t?'on target':'amber'===t?'just over':'over target'}`:`Target ${e}%`}),(0,f.jsx)(O,{testID:"gp-suggested-target",label:`Price for ${e}% food cost`,value:P.suggested?(0,u.money)(P.suggested):'\u2014',colour:x.colours.gold,sub:P.suggested?'inc VAT':'Add amounts first'})]}),i?(0,f.jsxs)(r.default,{testID:"gp-vat-aware",accessible:!0,accessibilityLabel:`VAT ${(0,u.money)(i.vatPence)} of the ${(0,u.money)(P.price)} goes to the tax office. GP on the price without VAT is ${(0,u.pct)(i.gpPct)}. With VAT left in it would wrongly look like ${(0,u.pct)(i.naiveGpPct)}.`,style:{alignItems:'center',gap:2},children:[(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["VAT ",o.vatPct,"%: ",(0,u.money)(i.vatPence)," of each ",(0,u.money)(P.price)," is VAT"]}),(0,f.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:["True GP ",(0,u.pct)(i.gpPct)," (ex VAT) \xb7 would look like ",(0,u.pct)(i.naiveGpPct)," with VAT left in"]})]}):null]})})(),y&&P.price&&!ae?z?(0,f.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(P.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(P.price)}`,onPress:async()=>{if(P.price)try{await(0,m.recipeCards)().update(e.id,{price:P.price},s),E(`Menu price set to ${(0,u.money)(P.price)}. The card now waits for sign-off again.`),W(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>W(!1)})]})]}):(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(P.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(P.price)} as the menu price for ${e.dish}`,onPress:()=>W(!0)}):null,F?(0,f.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:F}):null,(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]);const w='New dish creator',T={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},v=e=>{const t=(0,j.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):null},C=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},P=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function $({n:e,title:t,children:s,testID:i}){return(0,f.jsxs)(y.Box,{testID:i,children:[(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,f.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function S({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,f.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,f.jsx)(a.Muted,{children:e}),(0,f.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,f.jsx)(a.Muted,{children:n}):null]})}function D({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,w]=(0,i.useState)(''),[P,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(''),[R,M]=(0,i.useState)(e.menuPrice?'price':'gp'),[G,B]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[V,z]=(0,i.useState)(String(e.target)),[W,N]=(0,i.useState)(String(e.targetX??4)),O=t=>n({...e,...t}),F=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),U=h.vatPct,H=C(V)??e.target,q=C(W)??4,_='price'===R?v(G):E>0?'gp'===R?(0,u.suggestPrice)(E,H,U,h.pricePoints):(0,u.suggestForMultiple)(E,q,U,h.multipleBasis,h.pricePoints):null,Y=_?(0,u.gpOf)(E,_,U):null,X=_?(0,u.multipleOf)(E,_,U,h.multipleBasis):0,K=Y?(0,u.toneFor)(Y.gpPct,H):'ok',J=(0,u.suggestAllergens)(e,p,g),Q=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Z=(t,s)=>O({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),ee=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),te=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!_)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:H,targetX:q,menuPrice:_??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,f.jsxs)(r.default,{style:{gap:12},children:[(0,f.jsxs)($,{n:1,title:"Name and category",testID:"step-name",children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>O({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,f.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>O({category:t})},t))})]}),(0,f.jsxs)($,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[F.length?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:F.map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(`dish:${e.id}`)},e.id))})]}):null,(0,f.jsx)(a.Muted,{children:"Ingredients"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:w,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[ee.slice(0,24).map(e=>(0,f.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>Q(e.id)},e.id)),(0,f.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),P?(0,f.jsx)(A,{initial:b,onDone:e=>{I(!1),w(''),e&&Q(e)}}):null,e.lines.length?(0,f.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,f.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,f.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,f.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>O({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Z(n,{qty:C(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,f.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,f.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Z(n,{unit:e})},e)),l?null:(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Z(n,{wastePct:''===e.trim()?void 0:C(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,f.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,f.jsxs)(a.Row,{gap:10,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>O({portions:Math.max(1,Math.round(C(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,f.jsx)(S,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,f.jsxs)($,{n:3,title:"Price it",testID:"step-price",children:[(0,f.jsx)(y.Tabs,{value:R,onChange:M,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,f.jsx)(a.Chip,{label:`${e}%`,selected:H===e,onPress:()=>z(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:V,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===R?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,f.jsx)(a.Chip,{label:`${e}x`,selected:q===e,onPress:()=>N(String(e))},e)),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:W,onChangeText:N,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===R?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{size:24,children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:G,onChangeText:e=>B((0,j.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,{width:140,fontSize:24}]}),(0,f.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==R?(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"suggested-price",label:`Suggested menu price (inc ${U}% VAT)`,value:_?(0,u.money)(_):'\u2014',colour:x.colours.gold,sub:_?`${(0,u.money)(_/(1+U/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),_?(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{B((_/100).toFixed(2)),M('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,f.jsx)(r.default,{testID:"avg-menu-price",children:(0,f.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${_?` \xb7 this dish ${_>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(_-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(S,{testID:"big-gp",label:`GP (target ${H}%)`,value:Y?(0,u.pct)(Y.gpPct):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:Y&&E>0?(0,u.fmtX)(X):'\u2014',colour:x.colours.gold}),(0,f.jsx)(S,{testID:"big-profit",label:"Profit per plate (cash GP)",value:Y?(0,u.money)(Y.cashGp):'\u2014',colour:Y?T[K]:x.colours.muted}),(0,f.jsx)(S,{testID:"big-foodcost",label:"Food cost",value:Y?(0,u.pct)(Y.foodCostPct):'\u2014'})]}),(0,f.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",U,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,f.jsxs)($,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,f.jsx)(k,{value:e.photo,onChange:e=>O({photo:e})}),(0,f.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),J.length?(0,f.jsx)(r.default,{testID:"allergen-suggest",children:(0,f.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",J.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,f.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,f.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:J.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>O({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>O({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,f.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,f.jsxs)($,{n:5,title:"Save",testID:"step-save",children:[(0,f.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>te('draft'),style:{flexGrow:1}}),(0,f.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>te('ready'),style:{flexGrow:1}})]}),D?(0,f.jsx)(r.default,{testID:"creator-msg",children:(0,f.jsx)(a.T,{size:15,colour:D.startsWith('Saved')?x.colours.ok:x.colours.amber,children:D})}):null,D.startsWith('Saved')?(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),B(''),M('gp')}})]}):null]})]})}function k({value:e,onChange:t}){return(0,f.jsxs)(a.Row,{gap:10,children:[e?(0,f.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,f.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(a.Muted,{children:"No photo"})}),(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,f.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function A({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[w,T]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[P,I]=(0,i.useState)(n?.allergens??[]),[$,S]=(0,i.useState)(n?.servings?String(n.servings):''),[D,k]=(0,i.useState)(n?.servingName??''),[A,M]=(0,i.useState)(n?.supplier??''),G=!(!l.trim()||!C(p)||null==v(y)||''!==$.trim()&&!C($)),B={id:'probe',name:l,packSize:C(p)??0,packUnit:h,packPrice:v(y)??0,wastePct:0,servings:C($)??void 0,servingName:D.trim()||void 0},V=B.packSize&&B.packPrice?(0,u.perBaseUnit)(B):null,z=B.packPrice?(0,u.perServing)(B):null,W={name:l.trim(),packSize:C(p),packUnit:h,packPrice:v(y),wastePct:Math.min(90,C(w)??0),allergens:P,servings:C($)??void 0,servingName:D.trim().toLowerCase()||void 0,supplier:A.trim()||void 0};return(0,f.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,f.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:e=>b((0,j.sanitiseMoneyTyping)(e)),placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,f.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,f.jsx)(R,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,f.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,f.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:$,onChangeText:S,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,f.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:D,onChangeText:k,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),V||null!=z?(0,f.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(', '),children:(0,f.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(B,1)}`:'',V?`${(0,u.money)(V.pence)} a ${V.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:A,onChangeText:M,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:w,onChangeText:T,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,f.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,f.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,f.jsx)(a.Chip,{label:e.short,selected:P.includes(e.id),onPress:()=>I(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!G,onPress:()=>{if(n){const e=d.useGpCalc.getState();W.packPrice!==n.packPrice&&e.addPricePaid(n.id,W.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...W,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(W))}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function R({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,f.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,f.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const M={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function G({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),j=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),w='low'===g?j:[...j].reverse(),v=j.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,f.jsxs)(y.Box,{testID:"menu-gp",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,f.jsxs)(a.Muted,{children:[j.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,f.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),w.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,f.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,f.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",children:e.name}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Badge,{kind:M[e.status??'draft'].kind,label:M[e.status??'draft'].label}),e.category?(0,f.jsx)(a.Muted,{children:e.category}):null]}),(0,f.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,f.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,f.jsx)(a.T,{size:22,weight:"bold",colour:o?T[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,f.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,f.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,f.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,f.jsx)(r.default,{testID:"publish-msg",children:(0,f.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function B(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,f.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,f.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,f.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,f.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,f.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,f.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function V(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,f.jsxs)(y.Box,{testID:"calc-items",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,f.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,f.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,f.jsx)(A,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,f.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,f.jsx)(B,{}),m.map(e=>{return(0,f.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,f.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,f.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,f.jsx)(r.default,{testID:"items-msg",children:(0,f.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),T=(0,u.priceStats)(e,n),P=c!==String(e.wastePct),I=v(g),$=(0,u.perBaseUnit)(e),S=(0,u.perServing)(e),D=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:''}${$?`, ${(0,u.money)($.pence)} a ${$.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,f.jsx)(A,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,f.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,f.jsxs)(r.default,{accessible:!0,accessibilityLabel:D,style:{gap:2},children:[(0,f.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,f.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,f.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=S?`${(0,u.money)(S)} a ${(0,u.servingWord)(e,1)}`:'',$?`${(0,u.money)($.pence)} a ${$.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,f.jsx)(a.Muted,{children:"Latest"}),(0,f.jsx)(a.T,{weight:"bold",children:(0,u.money)(T.latest)})]}),(0,f.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,f.jsxs)(a.Muted,{children:["Average (",T.count,")"]}),(0,f.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(T.avg)})]}),T.count>1?(0,f.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,f.jsx)(a.Muted,{children:"Range"}),(0,f.jsxs)(a.T,{size:14,children:[(0,u.money)(T.min),"\u2013",(0,u.money)(T.max)]})]}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:e=>h((0,j.sanitiseMoneyTyping)(e)),placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[a.styles.input,L,{width:110}]}),(0,f.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,f.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,f.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),P?(0,f.jsx)(a.Button,{small:!0,label:"Save",disabled:null==C(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,C(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,f.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>w(!0)})]}),b?(0,f.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,f.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,f.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,f.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,f.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>w(!1)})]})]}):null]})}function W(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,f.jsxs)(y.Box,{testID:"calc-settings",children:[(0,f.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=C(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(B,{}),(0,f.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,f.jsxs)(a.Row,{gap:8,children:[(0,f.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,f.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=C(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,f.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,f.jsxs)(a.Row,{gap:6,children:[(0,f.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,f.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,f.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const N='#3A2F1E';function O({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,f.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,f.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,f.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1157,[812,779,17,319,219,385,85,777,816,905,845,906,909,876,920,867,804,889,907,840,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,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}),Object.defineProperty(_e,"dayKey",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return I}}),_e.parseDay=C,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return z}}),_e.LField=R,_e.RemoveBtn=G,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:i="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(i),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),v=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[$]=(0,n.useState)(()=>T(new Date(Date.now()-5184e5))),I=Object.values(j.deliveries??{}).filter(e=>e.date>=$).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(L,{testID:"kc-stock-value",label:"Stock value (last count)",value:v?(0,d.money)((0,u.countValue)(v)):'\u2014',sub:v?`${w(v.date)} \xb7 ${v.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(L,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(I),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(L,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?h.colours.amber:h.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(p.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(W,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(K,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(Q,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(o.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(o.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return H}}),_e.DayPicker=U,_e.ExactCount=_,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?w(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),o=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]);const j={ok:h.colours.ok,amber:h.colours.amber,red:h.colours.red};let k=0;const v=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${k++}`),$=e=>String(e).padStart(2,'0'),T=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function C(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),o=new Date(l,s-1,n);return o.getFullYear()!==l||o.getMonth()!==s-1||o.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const D=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},P=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},S=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),z=(e,t)=>`${S(e)} ${(0,d.unitName)(t,e)}`;function L({label:e,value:t,sub:n,colour:l=h.colours.gold,testID:i,onPress:r}){return(0,x.jsxs)(s.default,{testID:i,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(o.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:n}):null]})}function R({label:e,value:n,onChange:s,placeholder:i,testID:r,keyboard:c,width:a,said:d,money:u}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:u?e=>s((0,f.sanitiseMoneyTyping)(e)):s,placeholder:i,placeholderTextColor:"#7D776C",keyboardType:u?'decimal-pad':c??'default',inputMode:u?'decimal':void 0,style:[o.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function G({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:h.colours.accentBorder,backgroundColor:e?h.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(i.GoldX,{size:14}),(0,x.jsx)(o.T,{size:h.font.small,colour:h.colours.gold,children:l})]})}let N=0;const A=()=>({k:N++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),B=()=>N++,V=e=>({k:N++,ingId:e.ingId,name:e.name,packs:S(e.packs),size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?S(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),M=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),H=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function W({me:e,rid:t}){const[s,i]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{i(!1),e&&f(e)}}):a?(0,x.jsx)(E,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(p.Box,{testID:"deliveries",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(o.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(o.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),i(!0)},style:{minHeight:64}}),(0,x.jsx)(o.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(F,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function F({d:e,open:t,onToggle:i,onEdit:c,onDeleted:a}){const[p,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${I(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:i,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",D(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${S(e.packs)} at ${(0,d.money)(e.packPrice)} for ${z(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${S(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(o.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[S(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",z(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["Exact count ",S(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${I(e.date)}`,onPress:c}),p?null:(0,x.jsx)(G,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${I(e.date)}`,onPress:()=>m(!0)})]}),p?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${w(e.date)}.`)}}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function U({value:e,onChange:s,label:i}){const[r,c]=(0,n.useState)(P(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:T(),yday:T(new Date(Date.now()-864e5))})),u=!C(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:i}),(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(P(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(P(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${i}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=C(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[o.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:h.colours.goldLight,children:u?'Type the date as day/month/year':I(e)})]})}function E({me:e,edit:t,onDone:s,rid:i}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(i),[f,j]=(0,n.useState)(t?.date??T()),[k,$]=(0,n.useState)(t?.supplier??''),[I,D]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(V):[A()]),[L,G]=(0,n.useState)(''),N=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),B=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),W=S.filter(e=>!H(e)),F=W.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(p.Box,{testID:"delivery-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(U,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(R,{testID:"delivery-supplier",label:"Supplier",value:k,onChange:$,placeholder:"Supplier name"}),N.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:N.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:k.trim()===e,onPress:()=>$(e)},e))}):null,(0,x.jsx)(R,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:I,onChange:D,placeholder:"e.g. 10452"}),(0,x.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(o.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(q,{n:t+1,l:e,ingredients:a,onChange:t=>B(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(o.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,A()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(F)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(o.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(F)})]}),L?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:L})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!C(P(f)))return void G('Check the date.');if(!W.length)return void G('Add at least one item.');const n=W.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??v('del'),date:f,supplier:k.trim(),...I.trim()?{ref:I.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:W.map(M)},o=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),i=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=i.lines.filter(e=>!o.has(e.ingId)).length;s(`Saved the delivery of ${w(f)}: ${i.lines.length} price${1===i.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function q({n:e,l:t,ingredients:n,onChange:s,onRemove:i}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],p=e=>s({ingId:e.id,name:e.name,size:S(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,x.jsxs)(o.T,{weight:"semibold",center:!0,colour:h.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(R,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",z(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${z(t.packSize,t.packUnit)}`,onPress:()=>p(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(R,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(R,{money:!0,testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Pack size is in"}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(_,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(o.T,{weight:"bold",center:!0,colour:m?h.colours.gold:h.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),i?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(G,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:i})}):null]})}function _({n:e,l:t,onChange:n,word:s="Item"}){const i=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=i&&i>0&&null!=c&&r>0?c*r/i:null,u=!(!t.count.trim()||i&&i>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(R,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(R,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:u?h.colours.amber:null!=a?h.colours.goldLight:h.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function K({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[i,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return i?(0,x.jsx)(J,{me:e,edit:'new'===i?void 0:i,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(p.Box,{testID:"counts",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(o.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${I(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?h.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:18,center:!0,children:w(e.date)}),(0,x.jsxs)(o.T,{center:!0,weight:"bold",colour:h.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(o.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${X(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(o.T,{center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[X(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${I(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(G,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${I(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${w(e.date)}.`)}})]})]}):null]},e.id)})]})}const Y=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${z(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),X=e=>`${S(e.qty)} ${Y(e.unit,e.qty,e)}`;function J({me:e,edit:s,last:i,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??T()),[f,j]=(0,n.useState)(s?.by??e),[k,$]=(0,n.useState)(''),[I,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:S(e.qty),unit:e.unit}]))),[D,P]=(0,n.useState)(''),L=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=L.filter(e=>!k.trim()||e.name.toLowerCase().includes(k.trim().toLowerCase())),N=e=>{const t=I[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=L.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(U,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(R,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(R,{testID:"count-search",label:"Find an item",value:k,onChange:$,placeholder:"Search"}),G.map(e=>{const n=I[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=i?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?h.colours.accentBorder:h.colours.border,backgroundColor:h.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[(0,d.money)(e.packPrice)," for ",z(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${X(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${Y(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[o.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:null==c?h.colours.amber:h.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${L.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Stock value so far"}),(0,x.jsx)(o.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:h.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:[A.length," of ",L.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.amber,children:D})}):null,(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(o.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void P('Enter at least one count.');if(!f.trim())return void P('Say who counted.');const e={id:s?.id??v('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${w(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(p.Box,{testID:"count-form",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function Q({cards:e,actor:t}){const{ingredients:i,settings:c,cardCosts:a,setSettings:m,deliveries:y}=(0,r.useGpCalcView)(),[f,k]=(0,n.useState)(null),[v,$]=(0,n.useState)(''),I=(0,n.useMemo)(()=>(0,d.menuOverview)(e.map(e=>{const t=(0,d.cardCostSummary)(a?.[e.id],i,c,e.price);return{id:e.id,name:e.dish,gp:t.gp,foodCostPct:t.foodCostPct,tone:t.tone,price:t.price,perPortion:t.perPortion,c:e,s:t}})),[e,a,i,c]),[C]=(0,n.useState)(()=>T(new Date(Date.now()-11232e5))),D=(0,n.useMemo)(()=>(0,d.marginDrops)(Object.values(y??{}),C).filter(t=>e.some(e=>e.id===t.dishId)),[y,C,e]),P=(0,d.foodCostTargetOf)(c.defaultTarget),S=I.filter(e=>null!=e.s.gp),z=S.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(p.Box,{testID:"dish-gp",children:[(0,x.jsx)(o.T,{size:20,weight:"bold",center:!0,colour:h.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(o.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target GP"}),(0,x.jsxs)(o.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-down",label:"\u2212",accessibilityLabel:`Lower the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target food cost ${P} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Target food cost"}),(0,x.jsxs)(o.T,{testID:"target-fc",size:28,weight:"bold",center:!0,colour:h.colours.gold,children:[P,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"target-fc-up",label:"+",accessibilityLabel:`Raise the target food cost, now ${P} percent`,onPress:()=>m({defaultTarget:(0,d.targetGpForFoodCost)(P+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(o.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-down",label:"\u2212",accessibilityLabel:`Lower the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.max(0,c.vatPct-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`VAT on menu prices ${c.vatPct} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"VAT on menu prices"}),(0,x.jsxs)(o.T,{testID:"vat-pct",size:22,weight:"bold",center:!0,colour:h.colours.goldLight,children:[c.vatPct,"%"]})]}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",testID:"vat-up",label:"+",accessibilityLabel:`Raise the VAT rate, now ${c.vatPct} percent`,onPress:()=>m({vatPct:Math.min(30,c.vatPct+1)}),style:{minWidth:52,minHeight:52}})]}),D.length?(0,x.jsxs)(l.default,{testID:"gp-price-alerts",accessibilityLiveRegion:"polite",style:{gap:6,padding:10,borderRadius:14,borderWidth:1.5,borderColor:h.colours.amber,backgroundColor:h.colours.amberBg},children:[(0,x.jsx)(o.T,{weight:"semibold",center:!0,colour:h.colours.amber,accessibilityRole:"header",children:"Price change alerts"}),D.slice(0,8).map(e=>(0,x.jsxs)(o.T,{size:h.font.small,center:!0,children:[e.dish,": GP ",(0,d.pct)(e.before)," \u2192 ",(0,d.pct)(e.after)," after the ",e.supplier||'delivery'," prices on ",w(e.date)]},e.dishId)),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:"Last 14 days. Check the price or the portion."})]}):(0,x.jsx)(o.T,{testID:"gp-price-alerts-none",size:h.font.small,center:!0,colour:h.colours.muted,children:"No price change alerts in the last 14 days."}),(0,x.jsxs)(o.T,{center:!0,colour:h.colours.goldLight,children:[S.length," of ",I.length," dishes costed \xb7 ",z," under target"]}),(0,x.jsx)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,accessibilityRole:"header",children:"Menu overview: weakest first (lowest GP, highest food cost)"}),i.length?(0,x.jsx)(o.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},o=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),i=l.ingredients.filter(e=>e.name.trim()&&!o.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);i.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...i]}),n+=i.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),v?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(o.T,{center:!0,colour:h.colours.goldLight,children:v})}):null,I.map(({c:e,s:n})=>{const i=f===e.id,r=n.tone?j[n.tone]:h.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, food cost ${(0,d.pct)(n.foodCostPct??0)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:i},accessibilityLabel:`${u} ${i?'Tap to close':'Tap to cost it'}`,onPress:()=>k(i?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:h.colours.border,backgroundColor:e?h.colours.goldTint:h.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(o.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(o.T,{testID:"dish-gp-fc",size:h.font.small,center:!0,weight:"semibold",colour:j[(0,d.foodCostTone)(n.foodCostPct??0,P)],children:["Food cost ",(0,d.pct)(n.foodCostPct??0)," (target ",P,"%)"]}),(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(o.T,{size:h.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(o.T,{size:h.font.small,center:!0,colour:h.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),i?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),I.length?null:(0,x.jsx)(o.T,{center:!0,colour:h.colours.muted,children:"No recipe cards yet."})]})}},1175,[812,17,385,85,777,779,905,858,847,906,907,804,889,1176,1180,1157,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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1177,[1178,928,899,856,880,1179,1038]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1178,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t=null},1179,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1180,[17,85,780,777,905,858,908,804,889,1157,1181,8]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1181,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1182,[812,1183,17,385,85,409,777,876,851,863,804,1184,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1184,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1185,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1186,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1186,[17,777,858,1187,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1187,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1188,[812,1033,1183,17,1189,219,385,409,85,1191,1192,1193,777,816,876,851,1034,804,889,1199,1184,1057,1035,1194,856,1195,1200,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1189,[17,385,85,1190,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1190,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1191,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1192,[17,85,777,812,876,851,1191,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1193,[812,1191,17,385,85,777,884,876,1071,863,804,1184,1057,1194,856,1195,1192,1196,1198,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1194,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1195,[17,85,777,876,1008,1033,1064,1062,1194,804,856,1193,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1196,[1034,1197]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1197,[1034,1191]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1198,[17,85,777,812,1033,1034,1196,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1199,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1184,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1200,[1033,17,385,85,777,812,876,1197,1034,1201,1097,804,1188,1057,1051,1191,1196,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1201,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1202,[813,876,1203,1070,1183,923,924,17,975,976,219,385,278,85,777,858,1071,1204,1193,1163,1205,1059,805,1206,1140,851,863,804,1184,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1196,1198,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1203,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1204,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1205,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1206,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1207,[17,85,777,876,804,1057,1060,1205,1071,1208,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1208,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1209,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1210,[17,219,85,1057,876,1211,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1211,[]); +__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1212,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1213,[812,1214,779,1215,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1216,1219,1222,1224,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1214,[880,805,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1215,[17,1003,876,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1216,[219,1217]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1217,[1218,856]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1218,[928,903]); +__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1219,[813,1214,1033,779,812,1215,820,876,17,319,385,85,780,777,884,1003,1004,1220,804,889,1216,1221,8]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1220,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1221,[816,876,805]); +__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1222,[17,1033,362,219,85,777,876,1003,1221,1004,1223,804,889,1215,928,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1223,[1004,991]); +__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1224,[17,85,777,804,889,992,905,858,876,1033,1223,990,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.SpecialsEditor=function({rid:e,me:o,app:d,now:x}){const f=(0,n.useSpecials)(s=>s.current[e]??null),w=(0,n.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:k,clear:T,reuse:C,remove:S}=n.useSpecials.getState(),[P,v]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[I,R]=(0,s.useState)([]),[M,$]=(0,s.useState)(!1),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)(''),[z,O]=(0,s.useState)({}),[W,E]=(0,s.useState)(!1),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[V,Z]=(0,s.useState)(''),[q,J]=(0,s.useState)(!1),Q=async e=>{J(!0);const s=await(0,p.pickImageDataUrl)(1100,e);J(!1),s&&(B(s),Z(''))},X=(0,c.parsePrice)(G),ee={name:A,price:X,allergens:z,noAllergens:W},se=(0,c.itemProblems)(ee),le=''!==G.trim()&&(null===X||Number.isNaN(X)),te=(0,c.draftProblems)({photo:D,items:I,allergensChecked:M});return(0,b.jsxs)(a.default,{style:{gap:12},testID:"specials-editor",children:[(0,b.jsxs)(i.Card,{children:[(0,b.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(i.T,{weight:"semibold",children:"On the board now"}),f?(0,b.jsx)(i.Badge,{kind:"ok",label:"Live in customer app"}):(0,b.jsx)(i.Badge,{kind:"neutral",label:"Empty"})]}),(0,b.jsx)(a.default,{testID:"specials-last-updated",children:(0,b.jsx)(i.T,{colour:h.colours.goldLight,children:f?(0,c.lastUpdated)(f,x):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),f?(0,b.jsxs)(i.Muted,{children:[(0,c.boardSummary)(f),f.allergenCheck?` \xb7 allergens signed off by ${f.allergenCheck.by}`:'']}):null,f?.items.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(i.T,{weight:"semibold",children:e.name}),(0,b.jsx)(l.TakeawaySwitch,{itemId:e.id,dish:e.name,role:'chef'===d?'head-chef':'manager',me:o,signedOff:!!f.allergenCheck,priced:null!=e.price&&e.price>0})]},e.id)),(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return B((e=!0)?f?.photo??null:null),R(e?f?.items.map(e=>({...e}))??[]:[]),$(!1),N(''),U(''),_(''),O({}),E(!1),v(!0),void Z('');var e},style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!f,onPress:()=>Y({kind:'clear'}),style:{flexGrow:1}})]})]}),V?(0,b.jsx)(i.Banner,{kind:"success",children:V}):null,P?(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,b.jsx)(i.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,b.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"1. Photo of the board"}),D?(0,b.jsxs)(a.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,b.jsx)(u.BoardPhoto,{photo:D,onPress:()=>K(D),testID:"specials-editor-photo"}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>Q(!1)}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(null)})]})]}):(0,b.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,b.jsx)(i.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:q,onPress:()=>Q(!0),style:{flexGrow:1}}),(0,b.jsx)(i.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:q,onPress:()=>Q(!1),style:{flexGrow:1}})]}),(0,b.jsx)(i.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,b.jsxs)(i.T,{weight:"semibold",colour:h.colours.gold,children:["2. Typed specials (",I.length,")"]}),I.map(e=>(0,b.jsxs)(a.default,{style:{gap:4},children:[(0,b.jsx)(u.SpecialRow,{it:e,declared:[]}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>Y({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,b.jsxs)(a.default,{style:{gap:8,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,b.jsx)(i.Field,{label:"Dish name",value:A,onChangeText:N,placeholder:"e.g. Grilled hake, salsa verde"}),(0,b.jsx)(i.Field,{label:"Short description",value:L,onChangeText:U,placeholder:"One line for customers"}),(0,b.jsx)(i.Field,{money:!0,label:"Price (\xa3)",value:G,onChangeText:_,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),le?(0,b.jsx)(i.T,{size:13,colour:h.colours.red,children:"Type the price like 18.50"}):null,(0,b.jsx)(y,{map:z,none:W,onChange:O,onNone:e=>{E(e),e&&O({})}}),A.trim()&&se.length?(0,b.jsx)(i.Muted,{children:se.join(' \xb7 ')}):null,(0,b.jsx)(i.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!se.length||le,onPress:()=>{se.length||le||(R([...I,{id:j(),name:A.trim(),description:L.trim(),price:X,allergens:z,noAllergens:W||void 0}]),N(''),U(''),_(''),O({}),E(!1),$(!1))}})]}),I.length?(0,b.jsxs)(a.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:M?h.colours.ok:h.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,b.jsx)(i.Toggle,{label:"I have checked the allergens for every typed special",value:M,onChange:$}),(0,b.jsxs)(i.Muted,{children:["Signed off as ",o," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,te.length?(0,b.jsx)(a.default,{testID:"specials-problems",children:(0,b.jsx)(i.Muted,{children:te[0]})}):null,(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>v(!1)}),(0,b.jsx)(i.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!te.length,onPress:()=>{te.length||(k(e,{photo:D,items:I,allergensChecked:M},o,d),v(!1),Z('Specials board updated. Customers see it now in the app\u2019s Specials tab.'),setTimeout(()=>{(0,t.loadStaffTakeaway)(!0)},5e3))},style:{flex:1}})]})]}):f?(0,b.jsxs)(a.default,{style:{gap:8},testID:"specials-current",children:[f.photo?(0,b.jsx)(u.BoardPhoto,{photo:f.photo,onPress:()=>K(f.photo)}):null,f.items.map(e=>(0,b.jsx)(u.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,b.jsxs)(i.Card,{children:[(0,b.jsx)(i.T,{weight:"semibold",children:"Past boards"}),(0,b.jsxs)(i.Muted,{children:["The last ",w.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),w.length?w.map(s=>(0,b.jsxs)(a.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:h.colours.border,paddingTop:8,gap:6},children:[(0,b.jsx)(i.Row,{style:{justifyContent:'space-between'},children:(0,b.jsxs)(a.default,{style:{flex:1},children:[(0,b.jsx)(i.T,{weight:"medium",children:(0,c.whenText)(s.postedAt,x).replace(/^./,e=>e.toUpperCase())}),(0,b.jsxs)(i.Muted,{numberOfLines:2,children:[(0,c.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>{C(e,s.id,o,d),v(!1),Z(`Board from ${(0,c.whenText)(s.postedAt,x)} is live again.`)}}),(0,b.jsx)(i.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,c.whenText)(s.postedAt,x)}`,onPress:()=>Y({kind:'delete',id:s.id,label:(0,c.whenText)(s.postedAt,x)})})]})]},s.id)):(0,b.jsx)(i.Muted,{children:"No past boards yet."})]}),(0,b.jsxs)(i.Sheet,{visible:!!F,onClose:()=>Y(null),title:'clear'===F?.kind?'Clear the specials board?':'delete'===F?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,b.jsx)(i.Muted,{children:'clear'===F?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===F?.kind?`The board from ${F.label} will be removed from Past boards. This can\u2019t be undone.`:F?`\u201c${F.label}\u201d will be taken off this draft.`:''}),(0,b.jsxs)(i.Row,{gap:8,children:[(0,b.jsx)(i.Button,{kind:"ghost",label:"Keep it",onPress:()=>Y(null)}),(0,b.jsx)(i.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===F?.kind?'Yes, clear the board':'delete'===F?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===F?.kind&&(T(e,o),v(!1),Z('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===F?.kind&&S(F.id),'remove-item'===F?.kind&&R(I.filter(e=>e.id!==F.id)),Y(null)}})]})]}),(0,b.jsx)(u.PhotoZoom,{photo:H,onClose:()=>K(null)})]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),o=e(r(_d[3])),a=e(r(_d[4])),i=r(_d[5]),n=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),u=r(_d[11]),b=r(_d[12]);let x=0;const j=()=>`sp-${Date.now().toString(36)}${(x++).toString(36)}`;function y({map:e,none:s,onChange:l,onNone:t}){return(0,b.jsxs)(a.default,{style:{gap:6},testID:"special-allergens",children:[(0,b.jsx)(i.T,{size:13,weight:"medium",colour:h.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,b.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:d.ALLERGENS.map(t=>{const a=e[t.id],n='contains'===a?h.colours.redBg:'may'===a?h.colours.amberBg:h.colours.surface2,d='contains'===a?h.colours.red:'may'===a?h.colours.amber:h.colours.border;return(0,b.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===a?'contains':'may'===a?'may contain':'not listed'}`,disabled:s,onPress:()=>l((0,c.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:d,backgroundColor:n,opacity:s?.35:1},children:(0,b.jsxs)(i.T,{size:13,weight:"medium",colour:a?h.colours.text:h.colours.muted,children:[t.short,'may'===a?' (may)':'']})},t.id)})}),(0,b.jsx)(i.Toggle,{label:"None of the 14 allergens",value:s,onChange:t})]})}},1225,[17,1158,1159,385,85,777,910,845,911,804,889,1226,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1226,[813,17,319,378,385,278,85,1227,777,910,845,911,863,804,1019,8,1229]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1227,[901,17,1228,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1228,[880,899]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1229,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1230,[843,1028,17,219,385,85,780,858,804,777,1231,1104,1232,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1231,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1232,[1233,1234,1236,1235,1237,1018,1238]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1233,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1234,[824,805,831,834,856,1018,1235]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1235,[843,219,856,1233]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1236,[17,858,845,853,851,1234,1233]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1237,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1238,[17,1234,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1239,[17,385,85,409,858,845,804,777,1230,1104,1240,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1240,[17,85,409,858,845,1232,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1241,[17,219,385,85,864,777,804,916,1242,1243,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1242,[856,806,928,971,916,1232,1243]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1243,[824,1244,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1244,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1245,[17,856,1242]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1246,[17,385,329,85,409,804,1190,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1247,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1248,[843,1099,861,13,17,1249,917,85,841,1250,1079,1055,777,845,851,1105,863,858,899,804,1187,848,995,998,1076,1107,1251,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1249,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1250,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1251,[17,385,85,862,863,1033,1252,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1252,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1253,[900,13,17,319,85,1227,1254,777,845,851,858,867,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1254,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1255,[13,17,777,1256,858,1241,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1256,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1257,[822,13,17,1258,777,851,858,804,1259,1263,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1258,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1259,[17,85,777,851,1260,1261,1262,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1260,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1261,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1262,[928,899,1261]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1263,[831,928,971,899,880,1260]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1264,[1265,1266,805,1267,1276,1277,1278,843,13,17,219,385,85,1227,1254,777,845,851,862,858,900,804,1279,1241,856,876,1226,910,911,920,1280,1263,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1265,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1266,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1267,[17,85,777,1268,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1268,[806,1033,1269,1271,1273,17,85,812,777,804,1270,1274,1275,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1270,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1271,[1272,1270]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1272,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1273,[1270]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1274,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1275,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1276,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1277,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1278,[17,385,85,409,777,804,1189,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1279,[17,85,1280,777,858,920,1259,1262,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1280,[17,85,1281,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1281,[1282]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1282,[17,780,1283,1312,1313,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1283,[1284]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1284,[1285,1286,1309,1311]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1285,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1286,[1287,1288,1289,1290,1291,1292,1293,1294,1295,1298,1302,1299,1303]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1287,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1288,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1289,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1290,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1295,[1296]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1299,[1300,1301]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1300,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1301,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1304,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1305,[1299]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1307,[1299,1287]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1308,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1309,[1310]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1311,[1310]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1312,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1313,[17,780,1314,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1314,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1315,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1316,[822,13,17,85,1280,777,851,858,804,1279,1262,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1317,[822,13,17,85,1257,777,858,876,851,863,804,1258,1262,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1318,[822,13,17,777,858,876,863,804,1279,1262,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1319,[822,13,17,777,858,876,804,1279,1262,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1320,[13,17,777,863,1140,1321,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1321,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1322,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1323,[843,13,17,1248,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1324,[13,17,85,1253,777,845,862,858,804,1278,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1325,[13,17,1326,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1326,[17,85,777,1099,804,1327,1328,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1327,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1328,[928,971,1327]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1329,[843,13,17,85,1255,777,845,851,863,858,804,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1330,[17,354,362,219,13,777,851,804,900,1331,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1331,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1332,[843,1262,13,17,85,777,845,851,863,858,864,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]})}},1333,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1334,[822,13,17,777,858,805,1262,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1335,[13,17,777,1336,1153,1262,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1336,[812,843,17,85,777,845,851,1153,1337,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1337,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1338,[13,17,856,1339,1410,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1339,[1053,779,805,806,1340,813,1341,1094,843,1140,1342,1343,1344,1091,1122,1345,1346,1351,1352,1209,1353,856,1358,1359,1360,1115,1113,920,1361,1152,891,1104,1362,17,1072,1184,1018,1087,1363,378,363,385,278,85,409,19,777,1240,1244,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1364,1108,1365,1371,1373,1376,1381,1375,1382,1385,1386,1117,1095,1096,862,1391,1229,1392,1239,1231,995,1397,1402,1403,1054,1052,1119,1405,1406,1407,1071,1171,1408,1170,1161,853,1354,1409,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1342,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1343,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1344,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1345,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1346,[17,378,385,409,85,1280,777,1171,779,998,1347,1348,1350,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1347,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1348,[17,378,385,278,395,85,409,779,777,804,1349,1350,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1349,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1350,[993,856,1349,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1351,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1352,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1353,[1167,17,219,385,85,777,1166,804,876,920,1354,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1354,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1355,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1355,[831,928,899,1356,880,1357]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1356,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1357,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1358,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1360,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1361,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1362,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1363,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1364,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1365,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1366,1368,1367,998,876,1108,1369,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1366,[813,843,17,1367,85,842,804,777,1109,1368,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1367,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1368,[1367,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1369,[17,368,278,85,842,982,1370,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[17,219,385,85,804,777,1171,1372,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1374,804,777,1375,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1376,[805,813,17,266,319,219,385,85,409,804,857,1377,777,999,916,1351,1379,880,1380,1381,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1377,[17,219,85,1378,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1378,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1379,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1381,[17,831,928,899,1380]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1382,[843,841,998,1383,1384]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1383,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1384,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1385,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1386,[1387,843,1095,998,17,85,777,1098,858,1116,1382,1096,863,1093,1117,1118,1119,804,1343,1389,1390,1115,1360,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1387,[17,362,385,85,858,920,876,996,1388,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1388,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1391,[1171,1387,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1375,858,998,845,1089,1076,1321,804,1343,1389,1390,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1392,[812,17,219,385,85,777,858,998,1393,804,1394,1396,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1393,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1394,[831,858,998,1393,1395,1396]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1395,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1396,[219,1395]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1397,[843,17,1188,1171,385,85,995,998,862,863,804,777,1398,1401,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1398,[1399,854,843,17,264,378,385,278,85,858,995,998,1400,863,804,1026,777,1401,1355,899,1343,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1399,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1400,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1401,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1403,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1404,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1405,[843,1383]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1406,[17,385,85,777,1405,804,1363,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1407,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1408,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[17,1005,876,926,816,1006,916,1355,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[805,813,857,17,219,385,85,409,899,804,777,1351,1411,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); -__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]})}},1412,[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]})}},1413,[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,{})}},1414,[13,17,1415,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])},1415,[17,856,1416,1557,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 H.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]),Y=_r(d[45]);_r(d[46]);var 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,Q.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,Q.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,K.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,K.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,J.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)(()=>{G.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,M.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)(z.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)(z.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'!==H.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'===H.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'===H.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.jsx)(D.AssistantRequestsButton,{go:Be,testID:"assistant-requests-top"}),(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'===H.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)(F.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(Y.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(U.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(Q.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(K.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.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)(W.OnboardingHost,{go:Be}),(0,le.jsx)(V.CoachHost,{})]})}},1416,[805,813,899,1192,1227,1209,1028,1025,891,1026,880,1032,1087,17,356,378,385,278,409,85,19,777,857,858,876,804,1417,1183,1057,884,1425,920,219,1430,1470,839,856,1472,1479,1480,1481,1189,1245,1482,1456,1483,1485,1454,1160,1229,1392,1231,1244,1487,1084,1086,1553,1554,1573,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1417,[805,1418,1095,1269,1419,812,822,1117,1118,1091,1122,1420,1114,1119,1405,1406,1057,1343,996,1120,1089,841,1384,1125,1422,1240,1423,1397,1078,1055,1090,17,85,777,1363,858,845,851,863,1321,804,1183,1098,1115,998,1360,1062,1161,1424,1231,899,1185,1402,862,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1418,[]); -__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])},1419,[806,17,85,777,899,1273,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[17,385,85,1421,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1186,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1424,[17,85,864,858,848,804,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1425,[1426,17,219,24,85,856,1427,920,804,1429,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1426,[]); -__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])},1427,[17,278,85,777,857,804,1428,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(' ')},1428,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1429,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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:n=!1}){const{rid:a,r:x,now:H,role:ae,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(a),ce=(0,p.useBookings)(a),ue=(0,p.useWaitlist)(a),ge=(0,p.useEvents)(a),xe=(0,p.useRatings)(a),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,S.useRealHistory)(a,H),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,H,pe??void 0),[x,ce,de,ge,pe,H.getTime()/6e4|0]),ke=(0,M.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),Ie=de.filter(B.LIVE),ve=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=Ie.filter(e=>(0,U.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,U.bookingNeedsAction)(e,Ie)),Ae=Ie.flatMap(e=>(0,I.readinessFor)(e,x,H).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Se=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Me=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,v.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(H),He=ke?(0,L.revenueHistory)(x,H,7).filter(e=>e.date.getDay()===H.getDay()).pop():void 0,Fe=ke?{today:186e3+Ne,last:He?{date:(0,v.ymd)(He.date),pence:He.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,a,Pe,Ne),We=j.CAN.takings(ae)&&(!(0,W.isLive)()||(0,W.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,H,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(H),(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)(ae,qe,{inStaffApp:Ye,live:(0,W.isLive)()}),Ve=(0,F.homeSetupNagsHidden)(a),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,st]=(0,l.useState)(!1),ot=ie.replace(' (example)',''),lt=j.CAN.manage(ae)?(0,ne.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,ne.jsxs)(b.default,{style:{gap:12},children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(i.DayView,{rid:a,day:Ue,today:re,app:"owner"})]}):(0,ne.jsxs)(b.default,{style:{gap:12},testID:n?'owner-home':'managers-home',children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(K.WhoBar,{}),qe&&'owner'!==qe.role?(0,ne.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ne.jsx)(X.MyTasksToday,{rid:a,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ae?(0,ne.jsx)(Z.TodaysTipsCard,{rid:a,today:re}):null,'staff'!==ae?(0,ne.jsx)(Z.TipsPotCard,{rid:a,today:re}):null,j.CAN.manage(ae)?(0,ne.jsx)(b.default,{testID:"home-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.jsx)(f.Button,{testID:"home-insights-toggle",kind:tt?'secondary':'primary',label:tt?'Hide insights':'Insights',accessibilityLabel:tt?'Hide insights':'Insights: business insights, stats and suggestions. Closed until you tap.',onPress:()=>st(e=>!e),style:{minHeight:56,width:'100%'}})}):null,j.CAN.manage(ae)&&tt?(0,ne.jsxs)(b.default,{testID:"home-insights-panel",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,ne.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.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%'}})}),(0,ne.jsx)(le.SuperProInsights,{go:e}),(0,ne.jsxs)(b.default,{testID:"home-insights-feed",style:{gap:12,width:'100%'},children:[(0,ne.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,ne.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ne.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,ne.jsxs)(f.T,{weight:"semibold",center:!0,children:[t.icon," ",t.title]}),(0,ne.jsx)(f.Muted,{center:!0,children:t.body}),t.action?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'center'}}):null]})},t.id)),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights'),style:{alignSelf:'center'}})]})]}):null,(0,ne.jsx)(ye,{split:De}),(0,ne.jsx)(te.BlocksBanner,{rid:a,now:H,by:ie}),(0,ne.jsx)(y.KitchenSignoffs,{rid:a,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(o.SeasonsTodo,{go:e}):null,(0,ne.jsx)(r.LastFoodBanner,{rid:a,now:H}),(0,ne.jsx)(d.NextTableFreeCard,{rid:a,now:H}),j.CAN.manage(ae)?(0,ne.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,ne.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,ne.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ne.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ae)?(0,ne.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:a,r:x,now:H,by:ie}):null]}),ze.elements,j.CAN.manage(ae)?(0,ne.jsx)(Y.PaydaysCard,{go:e}):null,(0,ne.jsx)(E.FadeIn,{children:(0,ne.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ne.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,ne.jsx)(S.ExampleBadge,{}):je.enough?(0,ne.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ne.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ne.jsx)(E.Gauge,{pct:Le?Se.pct:0,label:Le?Se.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,ne.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ne.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,je.enough?(0,ne.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,ne.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ne.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ne.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||Ie.length?(0,ne.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Live orders",value:"",accent:Ie.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${Ie.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${Ie.filter(e=>'table'===e.type).length} table`:`${Ie.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ne.jsx)(E.CountUp,{value:Ie.length})})}):null,ve.length>0?(0,ne.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ne.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,ne.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(z.TakingsTodayCard,{t:Fe,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ne.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ne.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,ne.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,ne.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ne.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,v.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ne.jsx)(f.T,{size:14,children:t.detail}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ge.days.length||Ge.requests)?(0,ne.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,ne.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ae)?(0,ne.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ne.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ne.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ne.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,ne.jsxs)(f.Row,{gap:4,children:[(0,ne.jsx)(G.Mark,{p:"facebook"}),(0,ne.jsx)(G.Mark,{p:"instagram"}),(0,ne.jsx)(G.Mark,{p:"tiktok"}),(0,ne.jsx)(G.Mark,{p:"youtube"})]}),(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ne.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ne.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ne.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ne.jsx)(B.SectionHead,{title:e})}),(0,ne.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ne.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ne.jsxs)(f.Card,{children:[0===Oe.length?(0,ne.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,ne.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ne.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,v.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ne.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ne.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),Ke?(0,ne.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,ne.jsx)(E.FadeIn,{children:(0,ne.jsx)(he,{rid:a,today:re})}):null,'owner'!==ae||V.IS_CAR?null:(0,ne.jsx)(f.Button,{testID:"home-customer-support",label:"Customer support",accessibilityLabel:"Customer support, send a message or a picture to CoverCharge",onPress:()=>e('more','support'),style:{minHeight:56,width:'100%'}}),(0,ne.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:a,by:ot,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]),n=_r(_d[4]),a=e(n),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]),I=_r(_d[21]),v=_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]),S=_r(_d[29]),M=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),H=_r(_d[33]),F=_r(_d[34]),W=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),_=_r(_d[41]),U=_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]),ne=_r(_d[56]);const ae=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 a=3/Math.sqrt(n);o[e]=a*t*s[e],o[e+1]=a*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)&&n.push(e);for(;n.length&&o(e)-o(n[n.length-1])<36;)n.pop();return[...n,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&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/I*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:v(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],S=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?.(M(s)))},M=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,F=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,W=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)} ${F}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${W?` ${W.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,n)=>(0,ne.jsx)(m.default,{testID:n,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,ne.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ne.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ne.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ne.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ne.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,ne.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,ne.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ne.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:F}),(0,ne.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),W?(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:W}):null]}):(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ne.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ne.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ne.jsxs)(a.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ne.jsx)(n.Defs,{children:(0,ne.jsxs)(n.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ne.jsx)(n.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ne.jsx)(n.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ne.jsx)(n.Line,{x1:ae,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.Circle,{cx:v(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ne.jsx)(n.Line,{x1:v(L.day),y1:10,x2:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:M(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:v(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ne.jsx)(b.default,{testID:"mt-axis",style:{height:H.AXIS_BAND+6,minHeight:H.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ne.jsx)(f.T,{size:H.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:v(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ne.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ne.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>S(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ne.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:M(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ne.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ne.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,ne.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>S(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,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ne.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: card + cash \u2212 card tips. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ne.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ne.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,ne.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ne.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ne.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,ne.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ne.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1430,[843,1140,1431,17,780,1184,1074,1075,1423,1343,861,1078,264,385,85,777,858,876,1210,1192,845,1159,863,1055,866,804,1183,1057,1139,1144,1145,1008,839,1149,886,899,915,1441,1442,1148,1443,1161,853,1446,1187,1208,856,1206,1031,1032,1066,1098,1397,1152,1342,1464,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."})]})}},1431,[1053,1033,805,1418,812,1432,1433,1435,1436,1437,1202,1031,1032,1008,1014,17,385,85,777,841,1438,816,862,1055,861,804,1057,858,1186,926,927,876,1439,1392,998,1440,1005,1142,892,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)},1432,[812,17,85,777,1140,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)},1433,[843,17,219,85,777,858,998,1153,1262,899,1337,1434,8]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1434,[843,1284]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1435,[17,85,777,998,1347,804,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1436,[17,85,777,998,863,1400,805,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1437,[]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1438,[17,1033,85,804,777,1259,1262,8]); -__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1439,[17,85,777,998,1367,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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),S=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>C(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>C(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>f(null),onSave:t=>{y.update(e.id,t),f(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",S(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>f(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:I,onCancel:()=>f(null),onSave:t=>{y.add(e,t),f(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>f('new')}),(0,k.jsxs)(r.Sheet,{visible:!!p,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:p?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{p&&y.remove(p.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{f.useOrderLists.getState().ensure(e)},[e]);const s=(0,f.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,f.orderSettingsOf)(e);(0,f.useOrderLists)(t=>t.settings[e]);const l=f.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),f=(0,s.privateClockVenue)(e),[p,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[S,v]=(0,n.useState)(!1),[C,I]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(f)return;v(!0),I('');const t=await(0,b.getFix)();if(v(!1),'object'!=typeof t)return void I('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),I(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:f?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),f?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),f?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:S?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:S,onPress:()=>{B()}}),C?(0,k.jsx)(r.Muted,{size:13,children:C}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:p,onChangeText:j,onBlur:()=>R(p,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(p,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),f?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"The full CookSafe log is in the food safety menu: CookSafe log."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_r(_d[5])),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},S=[1,2,3,4,5,6,0],v=['on_shift','everyone','managers','head_chef','kitchen','foh'],C=e=>e.replace(' (example)',''),I={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:C(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[v.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:C(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,f]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),p=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{f(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:S.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),p?(0,k.jsx)(r.Muted,{size:13,children:p}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!p,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>f.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1440,[812,912,17,362,385,85,777,804,1005,1006,876,1010,1011,1012,913,1068,899,1029,916,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1441,[]); -__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7])},1442,[17,385,85,777,804,1148,1441,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1443,[886,779,816,813,822,862,1039,1444,17,909,319,362,219,385,85,777,858,876,863,804,1183,1057,1220,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1444,[482,1445]); -__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}});var t={}},1445,[]); -__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.ProgressBar=L,_e.useSetupDone=F,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,T.useCtx)(6e4),n=F(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=k.SETUP_STEPS.findIndex(e=>e.id===a),s=k.SETUP_STEPS[e+1]?.id??null;return(0,R.jsx)(A,{id:a,wizard:!0,onBack:()=>l(e>0?k.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=k.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,R.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{gap:12,children:[(0,R.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsxs)(m.T,{size:20,weight:"bold",colour:C.colours.gold,children:["Set up ",t.name]}),(0,R.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,R.jsx)(L,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,R.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,R.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:C.colours.border,backgroundColor:C.colours.surface,overflow:'hidden'},children:k.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,R.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:C.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,R.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?C.colours.gold:'transparent',borderWidth:1.5,borderColor:t?C.colours.gold:C.colours.border},children:(0,R.jsx)(m.T,{weight:"bold",colour:t?C.colours.onGold:C.colours.muted,children:t?'\u2713':s+1})}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"medium",children:e.title}),(0,R.jsx)(m.Muted,{children:e.sub}),o.length?(0,R.jsxs)(m.T,{size:13,colour:C.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,R.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=A,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return V}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=F(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,R.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",colour:C.colours.gold,children:"Finish setting up"}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]}),(0,R.jsx)(L,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,R.jsxs)(m.Muted,{size:13,children:["Next: ",k.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]),M=_r(_d[29]),R=_r(_d[30]);const I=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=[1,2,3,4,5,6,0],B=/^([01]\d|2[0-3]):[0-5]\d$/,D=e=>{const s=(0,M.parseMoneyInput)(e);return null!=s&&s>0?Math.round(100*s):null},O=e=>k.SETUP_STEPS.findIndex(s=>s.id===e)+1;function L({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,R.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,R.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:C.colours.gold,borderRadius:5}})}),(0,R.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function F(e){const s=(0,k.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=k.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:k.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function A({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,T.useCtx)(6e4),l=F(a),r=l.prog,d=(0,i.useLiveVenue)(),u=k.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=N[e];return(0,R.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsxs)(m.T,{size:12,weight:"semibold",colour:C.colours.gold,children:["STEP ",O(e)," OF ",k.SETUP_STEPS.length]}),s&&o?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,R.jsx)(m.T,{size:13,colour:C.colours.muted,children:"All steps"})}):null]}),(0,R.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,R.jsx)(L,{done:r.done,total:r.total})]}),(0,R.jsx)(b,{rid:a,done:(t="Saved.")=>{k.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,R.jsx)(m.Banner,{kind:"success",title:p}):null,(0,R.jsx)(G,{rid:a,id:e,title:u.title,onDone:x}),s?(0,R.jsxs)(m.Row,{gap:10,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,R.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const U=({wizard:e,onPress:s,disabled:t,label:n})=>(0,R.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const _=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function W({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,T.useHourly)(),d=(0,k.useSiteSetup)(e),u=(0,k.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,f]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,S.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,k.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),f(null)},z=!!p?.id&&(E=p.id,w.ROSTER.some(e=>e.id===E));var E;const M=p?D(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=M||z&&!p.wage);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,R.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,R.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?C.colours.gold:C.colours.border,backgroundColor:s?'#1d1a14':C.colours.surface}),children:[(0,R.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"semibold",children:e.name}),(0,R.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,k.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,R.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,k.accessOf)(e.level,e.role)})]},e.id))}),y?(0,R.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:C.colours.gold},children:(0,R.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,R.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,R.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,R.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,R.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,R.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Access level"}),(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:k.ACCESS_LEVELS.map(e=>(0,R.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,R.jsxs)(m.Muted,{size:13,children:["Uses the ",k.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Pay"}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,R.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,R.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,R.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,R.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,S.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,R.jsx)(m.Field,{money:!0,label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=M&&M<1271?(0,R.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,R.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,R.jsxs)(m.Row,{gap:8,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,R.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),k.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:k.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=M&&s.setRate(t,M);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),k.useSetup.getState().patch(e,{staffGrade:o}),k.useSetup.getState().setLook(t,p.look),f(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,R.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,R.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(_(d.grades[0]?.id??'')),f(null)}}),(0,R.jsx)(U,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const N={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,k.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,R.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,R.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,R.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,R.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':(0,y.builtInLogoCopy)(e)," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,R.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,R.jsx)(z.OrderAtTableCard,{rid:e,compact:!0}),u?(0,R.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,R.jsx)(U,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,T.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=$.filter(e=>{const s=n[e];return s&&(!B.test(s[0])||!B.test(s[1]))});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),I.map((e,s)=>{const t=$[s],l=n[t];return(0,R.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:C.colours.border,paddingTop:s?6:0},children:[(0,R.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,R.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"to"}),(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,R.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,R.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries($.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,R.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,R.jsx)(U,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,f.usePlan)(e),o=(0,f.planCounts)(n);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P.TablePlan,{startStep:"areas"}),(0,R.jsx)(U,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,R.jsx)(W,{...e,payList:!0})]})},staff:W,permissions:function({done:e,wizard:s}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E.PermissionsScreen,{}),(0,R.jsx)(U,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,k.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,R.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,R.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,R.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,R.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,R.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,R.jsx)(U,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),a=(0,k.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,v.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,R.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,R.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:C.colours.border,padding:10},children:(0,R.jsx)(m.T,{size:14,colour:C.colours.goldLight,children:i})}),(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,v.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,R.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,R.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,R.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,R.jsx)(U,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),k.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,T.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,R.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,R.jsx)(U,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},V=e=>function(){return(0,R.jsx)(A,{id:e})};function G({rid:e,id:s,title:t,onDone:n}){const o=F(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,R.jsxs)(g.default,{style:{gap:4},children:[(0,R.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),k.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,R.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,R.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1446,[888,887,813,812,1039,1447,1448,1449,1450,1452,17,385,85,857,884,777,858,876,1453,998,886,878,851,804,1057,1454,1457,1461,1462,840,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1447,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1448,[17,899]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1449,[17,831,899]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1450,[880,812,17,219,366,85,777,1451,899,804,1187,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1451,[]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1452,[17,385,777,899,804,1450,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.builtInLogoCopy=function(o){return'anchorage'===o?'The Anchorage logo in black and gold.':'Placeholder initials.'}},1453,[]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1454,[812,891,1140,899,780,1229,1231,17,264,362,219,385,85,409,864,777,858,1240,876,851,863,804,1183,1057,853,1055,1443,1160,1455,1456,1139,1145,1144,1008,839,1142,1148,1220,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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1455,[812,17,1227,1026,854,362,385,85,777,876,851,863,804,1183,1057,1220,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1456,[978,17,385,85,777,876,804,1057,1160,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1457,[812,17,1018,378,85,1108,1109,1365,1397,777,995,998,863,804,1057,999,1458,1459,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1458,[812,17,385,85,777,804,998,805,999,856,899,8]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1459,[17,85,777,998,1460,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1460,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1461,[805,1418,17,85,777,858,876,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.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 ')}},1462,[17,264,385,85,777,804,915,1463,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.'},1463,[928,899,876,856,915]); -__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 P}}),_e.useInsightsAccess=S,_e.SuperProInsights=_,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,D.jsx)(o.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,D.jsx)(_,{go:e})}):(0,D.jsx)(E,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.sales)return(0,D.jsx)(E,{});const r=i.sales;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Last 7 days"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=r.last7?(0,x.moneyGbp)(r.last7):'\u2014'}),r.missing7?(0,D.jsx)(l.Muted,{center:!0,children:`From ${r.days7} of ${r.days7+r.missing7} cash ups. ${r.missing7} ha${1===r.missing7?'s':'ve'} no card or cash total yet, so ${1===r.missing7?'it is':'they are'} not in the total.`}):null,(0,D.jsx)(l.Muted,{center:!0,children:null!=r.prev7?`The 7 days before: ${(0,x.moneyGbp)(r.prev7)}${null!=r.changePct?` (${r.changePct>=0?'up':'down'} ${Math.abs(r.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,D.jsx)(l.Muted,{center:!0,children:null!=r.sph7?`Spend per head ${(0,x.moneyGbp)(r.sph7)}, on the ${r.sphDays7} day${1===r.sphDays7?'':'s'} with takings and Covers`:'Spend per head shows once days have takings and Covers'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Takings by week"}),(0,D.jsx)(O,{values:r.weeks.map(e=>e.gross),w:300,h:70}),r.weeks.slice().reverse().map(e=>(0,D.jsx)(W,{a:`${(0,w.ukDate)(e.from)} \u2013 ${(0,w.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up${e.missing?`, ${e.missing} with no card or cash total`:''}`:e.missing?`Not enough data: ${e.missing} cash up${1===e.missing?'':'s'} with no card or cash total`:'No signed-off cash ups'},e.to)),(0,D.jsx)(l.Muted,{center:!0,children:"Takings are card + cash \u2212 card tips from signed-off cash ups (Gross only for a prepaid function), as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,D.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.stock)return(0,D.jsx)(E,{});const r=i.stock;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Low or out now"}),(0,D.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."}),r.low.length?r.low.map(e=>(0,D.jsx)(W,{testID:`low-${e.key}`,tone:e.out?k.colours.red:k.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,D.jsx)(l.Muted,{center:!0,children:r.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:`Price rises in the last ${w.RISE_DAYS} days`}),r.rises.length?r.rises.map(e=>(0,D.jsx)(W,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,$.gbp)(e.before)} \u2192 ${(0,$.gbp)(e.after)} a pack \xb7 ${(0,w.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,D.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,D.jsx)(l.Muted,{center:!0,children:r.lastCount?`Last full stock count ${(0,w.ukDate)(r.lastCount)}.`:'No full stock count yet.'})]}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.gp)return(0,D.jsx)(E,{});const r=i.gp;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,D.jsx)(A,{example:i.example}),i.example?(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:k.colours.gold,children:L(r.menu)}),null!=r.startMenu&&null!=r.menu?(0,D.jsx)(l.Muted,{center:!0,children:`${G(r.menu-r.startMenu)} points since ${(0,w.ukDate)(r.trend[0]?.week??'')}`}):null,(0,D.jsx)(O,{values:r.trend.map(e=>e.menu),w:300,h:80})]}):null!=r.menu?(0,D.jsx)(v.GpOverTime,{rid:s}):(0,D.jsx)(o.default,{testID:"insights-gp-not-enough",style:{width:'100%'},children:(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP"}),(0,D.jsx)(l.T,{weight:"semibold",center:!0,children:"Not enough data"}),(0,D.jsx)(l.Muted,{center:!0,children:`${r.fullyCosted} of ${r.costed} costed dishes have every recipe ingredient costed. Menu GP shows once ${w.MIN_FULLY_COSTED} or more are, so a part-costed dish cannot make GP look too high.`})]})}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),r.drops.length?r.drops.map(e=>(0,D.jsx)(W,{testID:`drop-${e.dishId}`,tone:k.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,w.ukDate)(e.date)}`},e.dishId)):(0,D.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Each dish over 3 months"}),r.dishes.length?r.dishes.map(e=>(0,D.jsx)(W,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const s=S(),n=C(),{list:i,source:r}=N(),[a,d]=(0,t.useState)('all');if(!s.clock)return(0,D.jsx)(E,{});const c='unsigned'===a?i.filter(e=>!1===e.signed):i,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,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,D.jsx)(A,{example:!!n}),(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${i.length})`,onPress:()=>d('all'),testID:"clock-filter-all"}),(0,D.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${i.filter(e=>!1===e.signed).length})`,onPress:()=>d('unsigned'),testID:"clock-filter-unsigned"})]}),(0,D.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:c.length?c.map(e=>(0,D.jsxs)(o.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${w.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,w.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:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?k.colours.amber:k.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,w.ukDate)(e.workDate)}`}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,children:`${w.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,D.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,D.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,D.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,D.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${w.CLOCK_DAYS} days.`})}),(0,D.jsx)(l.Muted,{center:!0,children:'server'===r?'From the server\u2019s timesheet audit.':'synced'===r?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=_r(_d[1]),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=e(i),l=_r(_d[5]),a=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),$=_r(_d[15]),x=_r(_d[16]),w=_r(_d[17]),b=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),D=_r(_d[23]);const P='SuperPro';function S(){const{role:e}=(0,j.useCtx)(6e4),s=(0,j.useSignedIn)(),t=(0,j.useInStaffApp)();return(0,w.insightsAccess)({viewRole:e,signed:s,live:(0,b.isLive)(),inStaffApp:t,perm:e=>(0,b.can)(e)})}function C(){return(0,y.useExamples)()&&!(0,b.isLive)()?I.INSIGHTS_SAMPLE:null}function N(){const e=C(),s=(0,h.useOwner)(e=>e.attendance),n=(0,h.useOwner)(e=>e.staff),[o,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(e||!(0,b.isLive)())return;let s=!0;return(0,b.readClockChanges)(w.CLOCK_DAYS).then(e=>{s&&e&&i((0,w.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,t.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const t=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:t(o),source:'server'};const i=(0,w.addDaysYmd)((new Date).toISOString().slice(0,10),-w.CLOCK_DAYS);return{list:t((0,w.clockChangesFromAttendance)(s,i)),source:'synced'}},[e,o,s,n])}function M(e){const s=C(),[n,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(s||!e||!(0,b.isLive)())return;let t=!0;return(0,b.readLoyaltyInsight)().then(e=>{t&&o(e?(0,w.loyaltyInsight)(e.raw,e.source):null)}),()=>{t=!1}},[s,e]),s?s.loyalty:e&&(0,b.isLive)()?n:null}function T(e,n){const o=C(),i=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,a.useBookings)(e),y=(0,a.useOrders)(e),$=(0,d.useReviews)(e=>e.reviews),x=(0,h.useOwner)(e=>e.attendance),b=(0,j.useHourly)(),k=(0,u.useGpCalcView)(),v=(0,a.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),D=(0,g.useShellStore)((0,f.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,t.useMemo)(()=>{if(o)return{example:!0,...o};const t=v.map(e=>({id:e.id,dish:e.dish,price:e.price,ingCount:Array.isArray(e.ingredients)?e.ingredients.length:void 0})),a=new Date,d=(0,w.salesInsight)(i,l,e,n,(0,s.coverOverridesFor)(e)),c=x.filter(e=>!e.voided&&'confirmed'===(0,h.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,j.paidMins)(e,a).paid,ratePence:b[e.staffId]??0})),u=x.filter(e=>!e.voided&&'awaiting'===(0,h.attStatus)(e)).map(e=>e.date);return{example:!1,sales:d,stock:(0,w.stockInsight)((I??[]).filter(e=>!e.group),D,(s,t)=>(0,p.fmtStockCount)(e,s,t),k.ingredients,Object.values(k.counts??{}),n),gp:(0,w.gpInsight)(k.ingredients,k.cardCosts??{},t,k.settings,Object.values(k.deliveries??{}),n),bookings:(0,w.bookingsInsight)(l,e,n),orders:(0,w.ordersInsight)(y,e,n),reviews:(0,w.reviewsInsight)($,e,n),labour:(0,w.labourInsight)(c,i,e,n,u),salesReport:(0,w.salesReportInsight)(r,e)}},[o,i,r,l,y,$,x,b,e,n,k,v,I,D])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,G=e=>`${e>0?'+':''}${e.toFixed(1)}`;function O({values:e,w:s=220,h:t=44,testID:n}){const l=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(l.length<2)return null;const a=Math.min(...l.map(e=>e.v)),d=Math.max(...l.map(e=>e.v))-a||1,c=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/d*(t-12),h=l[l.length-1];return(0,D.jsx)(o.default,{testID:n,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,D.jsxs)(r.default,{width:s,height:t,children:[(0,D.jsx)(i.Polyline,{points:l.map(e=>`${c(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:k.colours.gold,strokeWidth:2.5,fill:"none"}),(0,D.jsx)(i.Circle,{cx:c(h.i),cy:u(h.v),r:3.5,fill:k.colours.gold})]})})}function R({title:e,big:s,line:t,tone:o,onPress:i,testID:r,children:a,a11y:d,plan:c}){return(0,D.jsxs)(n.default,{testID:r,accessibilityRole:"button",accessibilityLabel:d,accessibilityHint:"Opens the detail",onPress:i,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??k.colours.gold,backgroundColor:e?k.colours.goldTint:k.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:e}),c?(0,D.jsx)(l.T,{size:11,weight:"semibold",colour:k.colours.goldLight,center:!0,children:c.toUpperCase()}):null,(0,D.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??k.colours.text,children:s}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.muted,children:t}),a,(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.goldLight,children:"Open \u203a"})]})}function A({example:e}){return(0,D.jsxs)(o.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.T,{size:20,weight:"bold",colour:k.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,D.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,D.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function B({title:e,sub:s,children:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.Badge,{kind:"gold",label:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]}),(0,D.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function _({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t),r=N(),l=M(n.loyalty);if(!n.any)return null;const a=(0,w.clockSummary)(r.list),d=(0,w.loyaltyLine)(l),c=s=>e('more',s),u=i.sales,h=i.stock,g=i.gp,p=i.bookings,f=i.orders,y=i.reviews,b=i.labour,v=i.salesReport,I=e=>w.INSIGHT_PLAN[e],C=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=n.sales||n.stock||n.gp||n.clock,E=n.bookings||n.noshows||n.orders||n.loyalty||n.reviews||n.labour||n.salesReports;return(0,D.jsxs)(o.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,D.jsx)(A,{example:i.example}),_?(0,D.jsxs)(B,{testID:"insights-group-superpro",title:P,sub:"Connected EPOS insights",children:[n.sales?(0,D.jsx)(R,{plan:I('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>c('insights-sales'),big:C(u.last7),line:null==u.last7?u.missing7?`Not enough data: ${u.missing7} cash up${1===u.missing7?'':'s'} in the last 7 days ha${1===u.missing7?'s':'ve'} no card or cash total`:'No signed-off cash ups in the last 7 days':`Last 7 days, card + cash \u2212 card tips from ${u.days7}${u.missing7?` of ${u.days7+u.missing7}`:''} cash-up day${u.days7+u.missing7===1?'':'s'}${u.missing7?` (${u.missing7} with no card or cash total)`:''}${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)}`:u.missing7?'Not enough data, the cash ups have no card or cash total':'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,D.jsx)(O,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,n.stock?(0,D.jsx)(R,{plan:I('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>c('insights-stock'),tone:h.low.length?k.colours.amber:void 0,big:h.low.length?`${h.low.length} low`:h.tracked?'None low':'\u2014',line:`${h.low.length?h.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):h.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${h.rises.length} price rise${1===h.rises.length?'':'s'} in ${w.RISE_DAYS} days`,a11y:`Stock. ${h.low.length} tracked items low or out. ${h.rises.length} price rises in ${w.RISE_DAYS} days`}):null,n.gp?(0,D.jsx)(R,{plan:I('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>c('insights-gp'),tone:g.drops.length?k.colours.amber:void 0,big:null==g.menu?'\u2014':L(g.menu),line:null==g.menu?`Not enough data: ${g.fullyCosted} of ${g.costed} costed dishes have every ingredient costed`:`Menu GP, ${g.fullyCosted} fully costed dishes${null!=g.startMenu?` \xb7 ${G(g.menu-g.startMenu)} pts in 3 months`:''} \xb7 ${g.drops.length} dish${1===g.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(g.menu)}. ${g.drops.length} dishes fell after a cost change`,children:(0,D.jsx)(O,{testID:"insight-gp-spark",values:g.trend.map(e=>e.menu)})}):null,n.clock?(0,D.jsx)(R,{plan:I('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>c('insights-clock'),tone:a.unsigned?k.colours.amber:void 0,big:String(a.total),line:`Edits in ${w.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 ${w.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,D.jsxs)(B,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[n.salesReports?(0,D.jsx)(R,{plan:I('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:C(v.gross),line:v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}${v.top.length?` \xb7 ${v.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}, ${C(v.gross)}`:'None yet')}):null,n.bookings?(0,D.jsx)(R,{plan:I('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,n.noshows?(0,D.jsx)(R,{plan:I('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?k.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}${n.sales?` (${(0,$.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,n.orders?(0,D.jsx)(R,{plan:I('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,$.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,n.reviews?(0,D.jsx)(R,{plan:I('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:y.low30?k.colours.amber:void 0,big:null!=y.avg30?`${y.avg30.toFixed(1)} \u2605`:'\u2014',line:`${y.count30} review${1===y.count30?'':'s'} in 30 days \xb7 ${y.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${y.avg30??'none'} stars from ${y.count30} reviews in 30 days`}):null,n.loyalty?(0,D.jsx)(R,{plan:I('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:d.big,line:d.line,a11y:`Loyalty. ${l?.members??'Not known'} members. ${l?.stampsMonth??'Not known'} stamps this month. ${l?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,n.labour?(0,D.jsx)(R,{plan:I('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=b.pct7&&b.pct7>35?k.colours.amber:void 0,big:null!=b.pct7?`${b.pct7}%`:'\u2014',line:null!=b.pct7?`Wages of takings on the ${b.days7} day${1===b.days7?'':'s'} with takings, last 7 days \xb7 ${C(b.labour7)} wages`:`Not enough data: no day in the last 7 has both signed-off hours and takings \xb7 ${b.paidHours7} signed-off hours`,a11y:`Wages and hours versus takings. ${b.pct7??'Not known'} percent over 7 days, ${b.paidHours7} hours`}):null]}):null]})}function E(){return(0,D.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function W({a:e,b:s,tone:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]})}},1464,[1465,17,385,85,780,777,858,1242,1008,905,876,895,897,864,1145,851,1466,1468,899,804,1057,1179,1469,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"coverOverridesFrom",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"coverOverridesFor",{enumerable:!0,get:function(){return c}});var o=r(_d[0]);const t={anchorage:{'2026-11-09':{covers:50,why:'BBC function, prepaid, 50 people (Gordon, 25 Nov 2026)'}}},n=(o,n)=>n?Object.fromEntries(Object.entries(t[o]??{}).map(([o,t])=>[o,t.covers])):{},c=t=>n(t,o.LIVE_VENUE_BUILD)},1465,[822]); -__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=l,_e.previousRange=function(e,n){const o=l(e,n);if('today'===n||'week'===n)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===n?1:0)-('today'===n?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===n?1:0)-('today'===n?1:0))};const[r,s]=o.from.split('-').map(Number),u=`${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=`${u.slice(0,7)}-${o.to.slice(8,10)}`;return{from:u,to:d<=c&&d>=u?d:c}},_e.changePct=function(t,e){return null==t||null==e||0===e?null:Math.round((t-e)/e*1e3)/10},_e.changeWords=function(t,e){if(null==t)return null;const n='today'===e?'yesterday':'week'===e?'last week':'last month';return 0===t?`No change vs ${n}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${n}`},_e.canSeeTakingsStats=function(t,e,n){return!('owner'!==t&&'manager'!==t||e&&!n)},_e.coversInRange=function(t,e){let s=0,l=0;for(const u of t){if(!u.date||!n(u.date,e))continue;if(!r(u.status))continue;const t=u.partySize||0;o(u)?s+=t:l+=t}const u=s+l;if(!u)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/u*100);return{total:u,walkIns:s,bookings:l,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,e,r){const l=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t)&&(s(t.status)||'noshow'===t.status));if(!l.length)return{rate:null,count:0,of:0,empty:!0};const u=l.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/l.length*1e3)/10,count:u,of:l.length,empty:!1}},_e.cancelRate=function(t,e,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const l=s.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(l/s.length*1e3)/10,count:l,of:s.length,empty:!1}},_e.takingsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{gross:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{gross:null,days:0,missing:u.length,missingDates:u}},_e.grossDays=u,_e.tipsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.combinedTips)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{tips:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{tips:null,days:0,missing:u.length,missingDates:u}},Object.defineProperty(_e,"completeTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"missingWords",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"takingsMissingWords",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return g}}),_e.tipsVsTakings=function(e,o,r){let s=0,l=0,u=0;for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals),d=(0,t.combinedTips)(c.vals);null==e||null==d||e<=0||(s+=d,l+=e,u+=1)}return u?{pct:g(Math.round(100*s)/100,Math.round(100*l)/100),days:u}:{pct:null,days:0}},_e.spendPerHeadInRange=function(t,n,o,r,s={}){const l=[...u(t,o,r).entries()].map(([t,r])=>({date:t,gross:r,covers:(0,e.coversOn)(n,o,t)+(s[t]??0)})),c=l.filter(t=>t.covers>0),d=l.length-c.length;if(!c.length)return{sph:null,covers:0,gross:null,days:0,noCovers:d};const f=Math.round(100*c.reduce((t,e)=>t+e.gross,0))/100,g=c.reduce((t,e)=>t+e.covers,0);return{sph:Math.round(f/g*100)/100,covers:g,gross:f,days:c.length,noCovers:d}},_e.labourCostInRange=h,_e.labourVsTakings=function(t,e,n,o,r){const s=u(n,o,r),l=s.size?Math.round(100*[...s.values()].reduce((t,e)=>t+e,0))/100:null,c=s.size?h(t,r,s):null;return{pct:m(c,l),labour:c,gross:l,days:s.size,awaiting:e.filter(t=>s.has(t)).length,labourAll:h(t,r)}},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return m}}),_e.repeatGuestPct=function(t,e,o){const r=new Set;for(const n of t){if(o&&n.restaurantId!==o)continue;if(!s(n.status)||n.date>=e.from)continue;const t=p(n);t&&r.add(t)}const l=new Set;let u=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!n(d.date,e))continue;const t=p(d);t&&!l.has(t)&&(l.add(t),u+=1,r.has(t)&&(c+=1))}return u?{rate:Math.round(c/u*1e3)/10,count:c,of:u,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.firstVisitDate=function(t,e){let n=null;for(const o of t)e&&o.restaurantId!==e||!s(o.status)||!o.date||(!n||o.date(null==t.status||'published'===t.status)&&n(t.createdAt.slice(0,10),e)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,e)=>t+e.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"NOT_SHOWN_YET",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return e.coversOn}});var t=_r(_d[0]),e=_r(_d[1]);const n=(t,e)=>t>=e.from&&t<=e.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function l(e,n){return'today'===n?{from:e,to:e}:'week'===n?{from:(0,t.weekStartOf)(e),to:e}:{from:`${e.slice(0,7)}-01`,to:e}}function u(e,o,r){const s=new Map;for(const l of e){if(l.rid!==o||!l.confirmedAt||!n(l.date,r))continue;const e=(0,t.tillTakingsOf)(l.vals);null!=e&&s.set(l.date,e)}return s}const c=(t,e)=>t.missing?null:e,d=(t,e,n)=>`Not enough data: ${t} cash up${1===t?' has':'s have'} no ${e} yet (${n.map(v).join(', ')})`,f=t=>`${t.length} cash up${1===t.length?' has':'s have'} no card or cash total yet (${t.map(v).join(', ')}), so ${1===t.length?'it is':'they are'} not in the total`,g=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function h(t,e,o){let r=0,s=!1;for(const l of t)!n(l.date,e)||l.ratePence<=0||l.paidMins<=0||o&&!o.has(l.date)||(r+=l.paidMins/60*l.ratePence,s=!0);return s?Math.round(r)/100:null}const m=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function p(t){const e=(t.phone||'').replace(/\s+/g,'').toLowerCase(),n=(t.email||'').trim().toLowerCase();return e.length>=7?`p:${e}`:n.includes('@')?`e:${n}`:null}const y='Not shown yet: GP and food cost %, table occupancy and top dishes. They need till sales, which CoverCharge does not have yet.',b={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.'},k=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,v=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,w=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1466,[839,1467]); -__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,u={}){const l=(0,r.weekStartOf)(o);return Array.from({length:d},(f,h)=>{const m=(0,r.addDaysYmd)(l,7*(h-d+1)),p=i(n,t,s,(0,r.addDaysYmd)(m,6),7,u).filter(r=>r.date<=o&&null!=r.gross),v=p.length?Math.round(100*p.reduce((r,n)=>r+n.gross,0))/100:null,y=p.reduce((r,n)=>r+n.covers,0);return{weekStart:m,gross:v,covers:y,days:p.length,sph:c(v,y)}})},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,l={}){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,h)=>{const m=(0,r.addDaysYmd)(o,h-i+1),p=f.get(m)?.vals??{},v=(0,r.tillTakingsOf)(p),y=d(t,s,m)+(l[m]??0),b=u(p.food),k=u(p.drink);return{date:m,gross:v,covers:y,sph:c(v,y),food:b,drink:k,foodPh:c(b,y),drinkPh:c(k,y)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.tillTakingsOf)(n.vals))},1467,[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=d,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return c}}),_e.salesInsight=function(e,t,r,o,s={}){const a={from:d(o,-6),to:o},i={from:d(o,-13),to:d(o,-7)},l=(0,n.takingsInRange)(e,r,a),c=(0,n.takingsInRange)(e,r,i),u=(0,n.spendPerHeadInRange)(e,t,r,a,s),f=u.sph,g=[];for(let t=7;t>=0;t--){const s=d(o,-7*t),a=d(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});g.push({from:a,to:s,gross:i.gross,days:i.days,missing:i.missing})}const p=null!=l.gross&&null!=c.gross&&c.gross>0&&!l.missing&&!c.missing?Math.round((l.gross-c.gross)/c.gross*1e3)/10:null;return{last7:l.gross,prev7:c.gross,changePct:p,days7:l.days,missing7:l.missing,sphDays7:u.days,sph7:f,weeks:g,empty:g.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=d(s,-30),c=[];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&&c.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})}c.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:c,lastCount:u?.date??null,empty:!a.length&&!c.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"MIN_FULLY_COSTED",{enumerable:!0,get:function(){return g}}),_e.fullyCostedIds=p,_e.gpInsight=function(n,r,o,s,a,i){const l=p(n,r,o,s),c=o.filter(e=>(r[e.id]?.lines?.length??0)>0).length;if(l.sizel.has(e.id)),f=(0,e.menuGp)(n,r,u,s),m=(0,e.gpHistory)(a,f,'3m',i),h=m.points.find(e=>null!=e.menu)?.menu??null,b=f.dishes.map(e=>{const t=m.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)),k=(0,t.marginDrops)(a,d(i,-14)).filter(e=>u.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{fullyCosted:l.size,costed:c,menu:f.menu,startMenu:h,trend:m.points.map(e=>({week:e.week,menu:e.menu})),dishes:b,drops:k,underTarget:f.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?b(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return y(n)},_e.clockChangesFromServer=function(e){return y(e.filter(e=>h.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:k(e.action,e.old_value),after:k(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 w}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:d(r,-6),to:r},a={from:d(r,-13),to:d(r,-7)},i={from:d(r,-29),to:r},l=(0,n.coversInRange)(o,s),c=(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:c.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=d(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:d(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,o,s=[]){const a={from:d(o,-6),to:o},i=(0,n.labourVsTakings)(e,s,t,r,a),l=e.filter(e=>e.date>=a.from&&e.date<=a.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:i.labour,takings7:i.gross,pct7:i.pct,days7:i.days,paidHours7:Math.round(l/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=v(e.members),r=v(e.stampsMonth),o=v(e.rewardsUsedMonth??e.rewardsMonth),s=v(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 d(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 c=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14,g=5;function p(e,n,r,o){const s=new Set;for(const a of r){const r=n[a.id];if(!r||!r.lines?.length)continue;if(null==a.ingCount||r.lines.length0||i.priceIsSuggested||s.add(a.id)}return s}const m={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'},h=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),b=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 k(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:b(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const y=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const w=30;const v=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1468,[908,906,1466]); -__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},1469,[]); -__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.useAssistantRequestInbox=x,_e.AssistantRequestsButton=function({go:e,testID:t}){const{visible:s,count:l}=x();return s?(0,b.jsx)(n.default,{style:{width:'100%',maxWidth:900,alignSelf:'center',paddingHorizontal:14,paddingTop:4,paddingBottom:8},children:(0,b.jsx)(o.Button,{testID:t??'assistant-requests-btn',label:l?`Assistant requests \xb7 ${l}`:'Assistant requests',accessibilityLabel:(0,p.assistantRequestsButtonLabel)(l),accessibilityHint:"Opens the list of changes your assistant has asked you to confirm or decline",kind:l?'primary':'secondary',onPress:()=>e('more','assistant-requests'),style:{minHeight:56}})}):null},_e.AssistantRequestsPage=function(){const{rows:e,load:t,visible:s}=x();if(!s)return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner can confirm or decline assistant changes, and only when an assistant is paired."})]});return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{gap:12,paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Each change waits for an owner to approve or decline it. Important changes ask a second time."}),(0,b.jsx)(w,{rows:e,onChanged:()=>{t()}})]})},_e.AssistantPendingCard=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(null),c=async()=>{try{r(await(0,l.assistantProposalsList)())}catch{r([])}};return(0,t.useEffect)(()=>{if(!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR)return;c();const t=setInterval(()=>{c()},2e4);return()=>clearInterval(t)},[e,s,n]),!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR?null:(0,b.jsx)(w,{rows:o,onChanged:()=>{c()},compact:!0})},_e.AssistantsPage=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),[s,r]=(0,t.useState)(''),[u,h]=(0,t.useState)(null),[p,x]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[A,I]=(0,t.useState)(null),[k,D]=(0,t.useState)(null),[C,S]=(0,t.useState)(null),[T,P]=(0,t.useState)(null),L=async()=>{try{P(await(0,l.assistantAccess)())}catch{P({plan:null,allowed:!1,reason:'Could not check this plan.'})}try{v(await(0,l.assistantList)())}catch{v([])}try{I(await(0,l.assistantProposalsList)())}catch{I([])}try{D(await(0,l.assistantAuditList)())}catch{D([])}};(0,t.useEffect)(()=>{e&&L()},[e]);const R=s.replace(/\D/g,''),$=!!T?.allowed,M=async()=>{x(!0),h(null);const e=await(0,l.assistantApprove)(R);x(!1),e.ok?(r(''),h({ok:!0,text:'Done. The assistant is paired. It can look things up and propose changes, which wait for an owner to confirm on their phone.'}),L()):h({ok:!1,text:e.message})},q=async(e,t)=>{x(!0),h(null);const s=await(0,l.assistantSetEnabled)(e.id,t);x(!1),s.ok?(h({ok:!0,text:t?`${e.label} is switched on.`:`${e.label} is switched off. It stays paired, and you can switch it on again.`}),L()):h({ok:!1,text:s.message})};return(0,b.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,b.jsx)(w,{rows:A,onChanged:()=>{L()}}):null,(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair your assistant"}),(0,b.jsx)(o.T,{center:!0,children:f}),(0,b.jsx)(o.T,{center:!0,children:"Ask your assistant, such as Grok Bot, to start CoverCharge sign-in. It will show 6 numbers. Only an owner of this venue can approve it. In the connected assistant it can answer questions about your venue and give advice from the data it is allowed to look up. It can propose a change; nothing is changed until an owner confirms it on their 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 a second time, with a plain warning of what is affected."}),!$&&T?(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-plan-blocked",children:T.reason||'Connecting an AI assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.'}):null,(0,b.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:s,onChangeText:e=>r(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,b.jsx)(o.Button,{testID:"assistant-approve",label:p?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs your AI assistant with this venue",disabled:!e||!$||p||6!==R.length,onPress:()=>{M()},style:{minHeight:56}}),e?null:(0,b.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,b.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!u,accessibilityLabel:u?.text,children:u?(0,b.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:u.ok?c.colours.goldLight:c.colours.amber,children:u.text}):null}),(0,b.jsx)(o.Muted,{center:!0,children:"Never send a personal app link to the bot. That link stays on your phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, it cannot read other venues, and it cannot change its own access or pairing."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(t=>(0,b.jsxs)(n.default,{testID:`assistant-row-${t.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:`${t.label} \xb7 ${!1===t.enabled?'switched off':'paired'}`}),(0,b.jsx)(o.Muted,{center:!0,children:`Since ${y(t.approvedAt)}. Last seen ${y(t.lastSeenAt)}.${t.ownerName?` Tied to ${t.ownerName}.`:''}`}),(0,b.jsx)(o.Toggle,{testID:`assistant-enabled-${t.id}`,label:"Assistant on",value:!1!==t.enabled,disabled:p||!e,onChange:e=>{q(t,e)},a11y:!1===t.enabled?`Switch on ${t.label}`:`Switch off ${t.label}`}),(0,b.jsx)(o.Button,{testID:`assistant-revoke-${t.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${t.label}`,onPress:()=>S(t),style:{minHeight:56}})]},t.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Activity log"}),(0,b.jsx)(o.Muted,{center:!0,children:"Everything this venue\u2019s assistants do is logged here, including look-ups. The assistant cannot change or skip this log."}),null===k?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):k.length?k.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-audit-${e.id}`,style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:e.detail||e.action}),(0,b.jsx)(o.Muted,{center:!0,children:`${y(e.at)}${e.actorName?` \xb7 ${e.actorName}`:''}`})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-audit-empty",children:"No activity yet."})]}),C?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>S(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,b.jsx)(o.T,{center:!0,children:`${C.label} stops working straight away. Any changes still waiting are cancelled. Your phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,b.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=C;S(null);const t=await(0,l.assistantRevoke)(e.id);h(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),L()},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>S(null),style:{minHeight:56}})]}):null]})};var t=_r(d[0]),s=e(_r(d[1])),n=e(_r(d[2])),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]);const y=e=>e?`${(0,r.niceDate)(new Date(e))} at ${(0,r.hm)(new Date(e))}`:'not yet',f='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.';function w({rows:e,onChanged:r,compact:u}){const h=(e??[]).filter(e=>'pending'===e.status),[f,w]=(0,t.useState)(null),[x,j]=(0,t.useState)(null),[v,A]=(0,t.useState)(null),I=async(e,t,n=!1)=>{w(e.id),j(null);const o=await(0,l.assistantProposalDecide)(e.id,t,n);if(w(null),o.ok){A(null);const e='decline'===t?'Declined. Nothing was changed.':'Done. The change has been made.';j(e),s.default.announceForAccessibility(e),r?.()}else j(o.message),s.default.announceForAccessibility(o.message)};return!h.length&&u?null:(0,b.jsx)(n.default,{testID:u?'assistant-pending-home':'assistant-pending-list',children:(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Waiting for an owner to confirm"}),e?h.length?h.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:8,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,alignItems:'center'},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,b.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${y(e.expiresAt)}.`:'']}):e.expiresAt?(0,b.jsx)(o.Muted,{center:!0,children:`Runs out at ${y(e.expiresAt)}.`}):null,e.canDecide?(0,b.jsxs)(n.default,{style:{gap:8,width:'100%',maxWidth:520,alignSelf:'center'},children:[(0,b.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:f===e.id?'Working\u2026':'Approve',accessibilityLabel:(0,p.assistantRequestActionLabel)('Approve',e.summary),accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!f,onPress:()=>{e.needsDoubleConfirm?A(e):I(e,'approve')},style:{minHeight:56}}),(0,b.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",accessibilityLabel:(0,p.assistantRequestActionLabel)('Decline',e.summary),disabled:!!f,onPress:()=>{I(e,'decline')},style:{minHeight:56}})]}):(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner of this venue can confirm or decline this on their phone."})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,b.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),(0,b.jsx)(n.default,{accessible:!0,accessibilityLiveRegion:"polite",accessibilityRole:"text",testID:"assistant-requests-status",style:{minHeight:x?void 0:0},children:x?(0,b.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:x}):null}),v?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>A(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,b.jsx)(o.T,{center:!0,accessibilityRole:"header",children:v.summary}),(0,b.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."}),v.warning?(0,b.jsx)(o.Muted,{center:!0,children:v.warning}):null,(0,b.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:f===v.id?'Working\u2026':'Yes, make this change',disabled:!!f,accessibilityLabel:`Yes, make this change: ${v.summary}`,onPress:()=>{I(v,'approve',!0)},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Go back",accessibilityLabel:`Go back without changing: ${v.summary}`,onPress:()=>A(null),style:{minHeight:56}})]}):null]})})}function x(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(0),[c,b]=(0,t.useState)(null),y=async()=>{try{const[e,t]=await Promise.all([(0,l.assistantList)(),(0,l.assistantProposalsList)()]);r((e??[]).length),b(t??[])}catch{r(0),b([])}};(0,t.useEffect)(()=>{if('owner'!==u.APP_VARIANT||u.IS_CAR||n||'owner'!==s||!e)return;y();const t=setInterval(()=>{y()},2e4);return()=>clearInterval(t)},[e,s,n]);const f=(c??[]).filter(e=>'pending'===e.status).length;return{visible:(0,p.canSeeAssistantRequests)({appVariant:u.APP_VARIANT,isCar:u.IS_CAR,inStaffApp:n,role:s,live:e,pairedCount:o}),count:f,rows:c,load:y,paired:o}}},1470,[17,264,85,777,899,863,804,856,1057,1471,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.assistantRequestActionLabel=function(t,s){const n=String(s||'this change').replace(/\s+/g,' ').trim().replace(/\.+$/,'');return`${t}: ${n||'this change'}`},e.assistantRequestsButtonLabel=function(t){const s=Math.max(0,Math.floor(Number(t)||0));return 1===s?'Assistant requests, 1 waiting':`Assistant requests, ${s} waiting`},e.canSeeAssistantRequests=function(t){return'owner'===t.appVariant&&!t.isCar&&!t.inStaffApp&&'owner'===t.role&&!!t.live&&(t.pairedCount??0)>0}},1471,[]); -__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"})]})}},1472,[817,1189,17,264,266,347,378,219,278,85,19,777,857,860,876,998,1036,1037,805,842,1034,1473,804,856,1057,1474,1477,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}}},1473,[1034]); -__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=C,_e.importQuestionnaireAccounts=B,_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. 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)(i.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:l}=(0,x.useCtx)(6e4),j='owner'===n,I=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],M=(0,p.useQuestionnaire)(e),{mark:P}=(0,p.useProvenance)(e),[A,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(M?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!I.some(n=>n.provider===e.provider)),[M,I]),W=(M?.accounts??[]).some((e,n)=>P('accounts',n,'provider'));return(0,y.jsxs)(i.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)(i.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:P('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:l})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>M&&B(e,M,l)}):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:`${I.length}`})]}),I.length?I.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(M?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(i.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)(i.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:P('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:T[e.status].kind,label:T[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)(C,{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=I.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:A,owner:j,by:l,onClose:()=>z(null)}),$?(0,y.jsx)(k,{rid:e,c:$,by:l,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),l=e(r(d[4])),i=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)(i.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 C({rid:e,compact:n}){const{role:o,me:l}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,C]=(0,t.useState)({}),[B,I]=(0,t.useState)(null),T=u.useAccounts.getState();return(0,y.jsxs)(i.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)(i.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)(i.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)(i.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)(i.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>C({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(i.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:()=>T.update(e,o.id,{accountNo:u},l,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>I(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>T.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:l})})}),(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)}),B?(0,y.jsx)(k,{rid:e,c:B,by:l,onClose:()=>I(null)}):null]})}function k({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)(i.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:["CoverCharge will stop listing ",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 B(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const l of n.accounts??[])o.some(e=>e.provider===l.provider)||s.add(e,{provider:l.provider,handle:l.handle,status:'listed',from:'questionnaire',addedBy:t})}function I({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,C]=(0,t.useState)(p?.handle??''),[k,B]=(0,t.useState)(p?.customName??''),[I,T]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const M=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${M?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(l.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(i.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:M?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),M?(0,y.jsx)(a.Field,{label:"Service name",value:k,onChangeText:B,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:()=>T(!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."]})]}),I?(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, 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:C,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:M?'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:M&&k.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:M?k.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:M&&!k.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)(i.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)(i.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)(i.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 T={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)(I,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1474,[812,17,362,385,278,85,777,1475,1476,804,1472,1057,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)},1475,[]); -__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)}))},1476,[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})]})}},1477,[17,385,85,777,860,1476,998,842,1478,1473,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'},1478,[]); -__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}},1479,[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])},1480,[1184,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1181,1443,1161,860,1185,853,1183,884,1360,998,843,1115,1198,1205,1071,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']}},1481,[17,1055,85,409,777,858,1141,1140,861,863,804,876,1183,1057,1148,1144,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}))},1482,[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]})]})}},1483,[805,1418,843,1392,17,85,777,858,860,866,845,851,1159,1105,863,804,1183,1057,1160,1161,853,1424,848,900,1484,8]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const a=!!e.settings.takeawayPaused;return(0,u.jsx)(l.Card,{highlight:a?r.colours.red:void 0,children:(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(l.T,{weight:"semibold",children:a?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,u.jsx)(l.Muted,{children:a?'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,u.jsx)(l.Toggle,{testID:"takeaway-pause",label:a?'Resume':'Pause',value:!a,onChange:a=>t.useStore.getState().updateSettings(e.id,{takeawayPaused:!a})})]})})},_e.TakeawayMenuList=function({me:e}){const[s,t]=(0,a.useState)(!1),c=(0,o.useStaffTakeaway)(e=>e.rows),h=(0,o.useStaffTakeaway)(e=>e.canSet),f=(0,o.useStaffTakeaway)(e=>e.busy),w=(0,o.useStaffTakeaway)(e=>e.error),y=(0,o.useStaffTakeaway)(e=>e.loadedAt);(0,a.useEffect)(()=>{s&&(0,o.loadStaffTakeaway)(!0)},[s]);const k=c?Object.values(c).sort((e,a)=>e.section.localeCompare(a.section)||e.dish.localeCompare(a.dish)):null,j=k?.filter(e=>e.onMenu).length??0,x=y>0&&null===c;return(0,u.jsxs)(l.Card,{children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",k?` \xb7 ${j} of ${k.length} available`:'']}),(0,u.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Hide':'Choose dishes',onPress:()=>t(!s),testID:"takeaway-menu"})]}),s?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(l.Muted,{children:"The whole menu shows on the takeaway page. Switch off what can\u2019t be done for takeaway today: guests see it as \u201cNot available for takeaway today\u201d. A dish also needs Head Chef allergen sign-off and a price."}),!h&&k?(0,u.jsx)(l.Muted,{children:"Only the Head Chef, a manager or an owner can change this."}):null,x?(0,u.jsx)(l.Banner,{kind:"warn",children:"Connect to the venue to see the takeaway menu."}):null,w?(0,u.jsx)(l.Banner,{kind:"warn",children:w}):null,k||x||w?null:(0,u.jsx)(l.Muted,{children:"Loading\u2026"}),(k??[]).map(a=>(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsxs)(l.T,{size:14,children:[a.dish,a.pricePence?` \xb7 ${(0,d.gbp)(a.pricePence)}`:'']}),(0,u.jsxs)(l.Row,{gap:4,children:['Specials board'===a.section?(0,u.jsx)(l.Badge,{kind:"gold",label:"Special"}):null,a.soldOut?(0,u.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,a.signedOff?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),a.pricePence?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),h?(0,u.jsx)(l.Toggle,{label:"Available for takeaway",a11y:`Available for takeaway, ${a.dish}`,value:a.onMenu,disabled:f===a.itemId,onChange:s=>{(0,o.setTakeawayAvailable)(a.itemId,s,e).catch(()=>{})}}):(0,u.jsx)(l.T,{size:14,colour:a.onMenu?r.colours.gold:r.colours.muted,children:a.onMenu?'Available':'Not today'})]},a.itemId))]}):null]})};var e,a=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),t=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),u=_r(_d[7])},1484,[17,85,777,858,851,1158,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 Ce}});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]),w=_r(d[16]),v=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),I=_r(d[22]),M=_r(d[23]),G=_r(d[24]),O=_r(d[25]),E=_r(d[26]),B=_r(d[27]),x=_r(d[28]),D=_r(d[29]),N=_r(d[30]),L=(e=N)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),q=_r(d[33]),Q=_r(d[34]),F=_r(d[35]),U=_r(d[36]),V=_r(d[37]),W=_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]),ye=_r(d[64]);const Ce=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},me=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:me,C:v.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=>me(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:me,C:O.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:me,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=>me(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:me,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:me,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:me,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:me,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:me,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:me,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:me,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:E.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:me,C:G.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:me,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:B.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:B.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:me,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:me,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:me,C:w.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:B.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:B.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:B.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:me,C:B.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:me,C:B.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:me,C:B.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:me,C:B.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:me,C:B.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:B.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:me,C:B.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:B.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:()=>Ce(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:me,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:me,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:me,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:me,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:me,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:me,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const Se=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(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:Se,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:Se,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:me,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:me,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:me,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:me,C:F.DisplaySettingsPage}]);const ke=e=>'owner'===e||'manager'===e;U.ASSISTANT_AVAILABLE&&V.ASSISTANT_UI&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:ke,C:U.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:ke,C:U.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:Y.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair your own AI assistant with a 6-digit code, switch it off, or unpair it',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantsPage}]),(0,y.register)([{id:'assistant-requests',title:'Assistant requests',sub:'Confirm or decline changes your assistant has proposed',group:'Start here',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantRequestsPage}]);const we=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:I.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:I.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:I.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:I.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:I.InsightsClockPage}]);const Pe=()=>{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)},Re=e=>we(e)&&Pe();(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:we,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:Re,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:Re,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:Re,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:we,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,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:we,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:me,C:z.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:me,C:z.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:me,C:z.Outbox}]);const Ae=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:Ae,C:J.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:J.optinsAllowed,C:J.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Ae,C:$.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Ae,C:K.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:Ae,C:X.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:Ae,C:Z.OrderSheetSettings},...ee.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Ae,C:(0,K.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Ae,C:te.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Ae,C:se.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:me,C:se.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Ae,C:se.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:Ae,C:ae.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:me,C:ie.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:me,C:ie.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:me,C:ie.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:me,C:re.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos and Show me where',group:'Start here',can:me,C:oe.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:me,C:ue.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:me,C:le.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:le.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ce.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ge.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:we,C:function(){const{rid:e,today:t}=(0,de.useCtx)(6e4);return L.default.createElement(ge.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(pe.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:me,C:ne.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(he.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:me,C:be.NightlyReportPage}]),(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:ye.UseOnComputerPage}]),(0,y.register)([{id:'support',title:'Customer support',sub:'Send a message or a picture to CoverCharge',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:fe.SupportChatPage}])},1485,[822,1050,856,1486,876,920,909,816,866,1488,1495,1497,1456,1498,1499,1501,1502,1160,1481,1503,1504,1505,1464,1201,1192,1483,1506,1454,1507,1508,17,1198,1181,1455,1443,1457,1513,1213,1519,1520,1470,1521,1446,1431,1522,1461,1523,886,1524,1525,1527,1187,1472,1528,1392,1474,1540,1081,1057,1202,1152,1544,1547,1550,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}),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)}},1486,[17,378,219,385,85,19,777,1026,1339,876,804,1487,1189,1482,1057,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}))},1487,[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}},1488,[812,1452,17,851,85,777,876,804,1057,884,885,1489,899,916,1031,1450,1490,1491,1493,996,1494,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},1489,[]); -__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])},1490,[812,17,85,777,804,876,1355,1354,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])},1491,[17,85,777,1492,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},1492,[831,928,899,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]},1493,[17,85,777,804,914,1022,899,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])},1494,[928,899]); -__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 h}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LINE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LITE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_TERM",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return C}}),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 U}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return $}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),h=(0,u.trialStatus)((0,l.defaultSimStart)(),e),[y,f]=(0,t.useState)(!1);return i.CAN.billing(n)?y?(0,p.jsx)(q,{onBack:()=>f(!1)}):(0,p.jsxs)(o.default,{style:{gap:10},children:[(0,p.jsx)(s.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,p.jsxs)(s.Card,{highlight:d.colours.gold,children:[(0,p.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,p.jsxs)(s.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[S,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-early-term",children:D})]}),(0,p.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:Y.map(([e,t])=>(0,p.jsxs)(o.default,{testID:e===b?'plan-early-guest-app':e===x?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,p.jsxs)(s.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,p.jsx)(s.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,p.jsx)(s.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,N,M,z,'Usual price',''],['plan-usual-pro',E,R,U,G,'Usual price',''],['plan-superpro',k,C,F,V,'1-year contract','No hardware included.']].map(([e,t,n,l,i,u,c])=>(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,p.jsxs)(s.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsx)(s.Muted,{center:!0,children:S}),(0,p.jsx)(s.Muted,{center:!0,children:l}),'plan-superpro'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-superpro-epos-line",children:B}):null,i.map(e=>(0,p.jsxs)(s.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),'plan-usual-lite'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-lite-ai",children:I}):null,c?(0,p.jsx)(s.Muted,{center:!0,children:c}):null]})},e)),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-terms",children:$}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>f(!0),style:{alignSelf:'center'}}),(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,p.jsxs)(s.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,p.jsx)(s.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,p.jsx)(s.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,p.jsx)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{children:"Free trial"}),(0,p.jsxs)(s.T,{weight:"bold",colour:d.colours.gold,children:[h.daysLeft," day",1===h.daysLeft?'':'s'," left"]})]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-h.daysLeft/h.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,p.jsxs)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'center'},gap:8,children:[(0,p.jsx)(s.T,{weight:"semibold",children:"Free customer support"}),(0,p.jsx)(s.Badge,{kind:"gold",label:"Included"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,p.jsx)(s.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},s=r(_d[2]),l=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]);const h=!0,y='Early adopter offer, usual prices, free trial, set-up guide',f='. 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',b='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',j='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',x='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.',_='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',v='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',I='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer.',O='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',S='+ VAT if applicable, per venue',L='Customer & Takeaway App',E='Full Restaurant Pro App',k='SuperPro',N='\xa349',R='\xa399',C='\xa3149',M='The lite version: core features for smaller venues.',U='Every feature, every app.',F='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',B='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.',D='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.',Y=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',D],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[b,A],['Free customer support','For the length of your subscription.'],[x,T],[v,v],[j,w]],z=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',b,P,j],G=['Owner dashboard and admin','Supplier links',x,v,b,P,j],V=['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',_,v,b,P,j],$='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. AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',K=[['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 q({onBack:e}){const[n,l]=(0,t.useState)([]);return(0,p.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,p.jsx)(s.H2,{children:"Set-up guide"}),(0,p.jsxs)(s.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",K.length," done."]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/K.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),K.map(([e,t],i)=>{const u=n.includes(i);return(0,p.jsx)(s.Card,{children:(0,p.jsxs)(s.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.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,p.jsx)(s.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,p.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(s.T,{weight:"semibold",children:e}),(0,p.jsx)(s.Muted,{children:t}),(0,p.jsx)(s.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>l(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,p.jsx)(s.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1495,[17,85,777,835,876,1496,804,1057,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'}},1496,[]); -__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]})]})]})}},1497,[805,1033,891,1418,813,812,822,1262,1438,17,385,393,85,864,777,858,876,845,851,863,804,1183,1057,1160,1443,1220,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])},1498,[843,17,85,1161,777,858,845,853,863,804,1183,1057,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])},1499,[1039,17,85,1500,814,857,777,876,804,1057,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}})},1500,[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])},1501,[17,1154,847,1057,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])},1502,[17,1032,1057,899,915,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])},1503,[17,1398,1057,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=b,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,u.useCtx)(6e4),n=(0,o.useBookings)(e),i=(0,d.useCashUp)(e=>e.cashUps),[j,w]=(0,s.useState)('day'),f=(0,h.hasAnyTakings)(i,e),k=(0,l.coverOverridesFor)(e),v=(0,h.dayRows)(i,n,e,t,14,k),$=(0,h.weekRows)(i,n,e,t,8,k),T=(0,h.averageSph)(v),S=(e,s,t,l,n)=>(0,p.jsxs)(a.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:c.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===l?'no takings entered':`spend per head ${l}`}, ${t}${n?`, ${n}`:''}`,children:[(0,p.jsx)(r.T,{center:!0,children:s}),(0,p.jsx)(r.T,{center:!0,colour:c.colours.muted,children:t}),(0,p.jsx)(r.T,{center:!0,weight:"semibold",colour:'No takings entered'===l?c.colours.muted:c.colours.goldLight,size:'No takings entered'===l?13:16,children:l}),n?(0,p.jsx)(r.Muted,{center:!0,children:n}):null]},e);return(0,p.jsxs)(a.default,{style:{gap:12},testID:"sph-screen",children:[(0,p.jsx)(r.Muted,{children:"Tip: spend per head is takings \xf7 Covers. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,p.jsxs)(r.Card,{highlight:c.colours.gold,children:[(0,p.jsx)(r.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==T?(0,p.jsx)(r.T,{size:22,weight:"semibold",colour:c.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,p.jsxs)(r.T,{size:34,weight:"bold",colour:c.colours.goldLight,testID:"sph-avg",children:[x(T)," ",(0,p.jsx)(r.T,{size:16,colour:c.colours.muted,children:"per head"})]}),(0,p.jsx)(r.Muted,{children:f?'Only days with a cash up are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has card and cash totals.'})]}),(0,p.jsxs)(r.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(r.Chip,{testID:"sph-day",label:"By day",selected:'day'===j,onPress:()=>w('day')}),(0,p.jsx)(r.Chip,{testID:"sph-week",label:"By week",selected:'week'===j,onPress:()=>w('week')})]}),'day'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by day"}),(0,p.jsx)(b,{testID:"sph-trend-day",label:"Spend per head trend by day",points:v.map(e=>({label:y(e.date),value:e.sph}))}),[...v].reverse().map(e=>S(e.date,y(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':x(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${x(e.foodPh)}, drink ${x(e.drinkPh)} per head`:void 0))]}):null,'week'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,p.jsx)(b,{testID:"sph-trend-week",label:"Spend per head trend by week",points:$.map(e=>({label:`w/c ${y(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...$].reverse().map(e=>S(e.weekStart,`w/c ${y(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':x(e.sph)))]}):null,(0,p.jsx)(r.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=_r(_d[1]),a=e(_r(_d[2])),n=_r(_d[3]),i=e(n),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]);const x=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function b({points:e,testID:l,label:o}){const[d,h]=(0,s.useState)(320),[u,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,l]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,u)),w=Math.max(0,j-b),f=e.slice(w,j),k=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)),T=e=>38+e*(k-76)/Math.max(1,f.length-1),S=e=>140-e/$*106,L=[];let D=[];f.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} ${x(e.value)}`).join(', ');return(0,p.jsxs)(a.default,{testID:l,onLayout:e=>h(e.nativeEvent.layout.width),style:{gap:8},children:[(0,p.jsxs)(a.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,p.jsx)(i.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,p.jsx)(n.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:c.colours.muted,children:x($*e/4)},e))}),(0,p.jsxs)(i.default,{width:k,height:170,children:[[0,1,2,3,4].map(e=>(0,p.jsx)(n.Line,{x1:0,x2:k,y1:S($*e/4),y2:S($*e/4),stroke:c.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,p.jsx)(n.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:c.colours.gold,strokeWidth:2.5},s)),f.map((e,s)=>(0,p.jsx)(t.default.Fragment,{children:null==e.value?(0,p.jsx)(n.Circle,{cx:T(s),cy:140,r:2,fill:"#444"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.Circle,{cx:T(s),cy:S(e.value),r:4,fill:c.colours.goldLight}),(0,p.jsx)(n.Text,{x:T(s),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:c.colours.goldLight,children:x(e.value)})]})},w+s))]})]}),(0,p.jsx)(a.default,{style:{flexDirection:'row',gap:12},children:f.map((e,s)=>(0,p.jsxs)(a.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':x(e.value)}`,children:[(0,p.jsx)(r.T,{center:!0,size:12,colour:c.colours.muted,children:e.label}),(0,p.jsx)(r.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?c.colours.muted:c.colours.goldLight,children:null==e.value?'No takings entered':x(e.value)})]},w+s))}),(0,p.jsxs)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(r.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,p.jsx)(r.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))})]})]})}},1504,[17,1465,85,780,777,858,1008,1467,804,1057,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])},1505,[17,85,1348,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])},1506,[17,776,1057,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:a,role:I,today:x,signedIn:j}=(0,b.useCtx)(),[D,P]=(0,t.useState)('today'),R=(0,r.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),W=(0,c.useOwner)(e=>(0,c.liveAttendance)(e.attendance)),C=(0,b.useHourly)(),S=(0,$.useReviews)(e=>e.reviews),N=(0,u.canSeeTakingsStats)(I,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,v.ensureReviewSync)(e,'manage')},[e]);const M=(0,u.rangeFor)(x,D),L=(0,u.previousRange)(x,D),G=(0,t.useMemo)(()=>R.filter(s=>s.restaurantId===e),[R,e]),_=(0,u.coversInRange)(G,M),O=(0,u.coversInRange)(G,L),B=(0,u.noShowRate)(G,M,e),F=(0,u.noShowRate)(G,L,e),A=(0,u.cancelRate)(G,M,e),H=(0,u.cancelRate)(G,L,e),V='today'===D?(0,h.laterTodayCovers)(G,x):0,z=(0,u.takingsInRange)(T,e,M),U=(0,u.takingsInRange)(T,e,L),E=(0,s.coverOverridesFor)(e),Y=(0,u.spendPerHeadInRange)(T,G,e,M,E),q=(0,u.spendPerHeadInRange)(T,G,e,L,E),J=(0,u.tipsInRange)(T,e,M),K=(0,u.tipsInRange)(T,e,L),Q=(0,t.useMemo)(()=>W.filter(e=>'confirmed'===(0,c.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,b.paidMins)(e,a).paid,ratePence:C[e.staffId]??0})),[W,C,a]),X=(0,t.useMemo)(()=>W.filter(e=>'awaiting'===(0,c.attStatus)(e)).map(e=>e.date),[W]),Z=(0,u.labourVsTakings)(Q,X,T,e,M),ee=(0,u.labourVsTakings)(Q,X,T,e,L),se=(0,u.tipsVsTakings)(T,e,M),te=(0,u.firstVisitDate)(G,e),ae=(0,u.repeatGuestPct)(G,M,e),ne=(0,u.repeatGuestPct)(G,L,e),ie=(0,u.reviewAverage)(S.filter(s=>s.restaurantId===e),M),oe='today'===D?'today':'week'===D?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(o.T,{weight:"semibold",size:y.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(o.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)(o.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(o.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:D===e.id,onPress:()=>P(e.id)},e.id))}),(0,f.jsx)(w,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${oe}`,value:(0,u.pctLabel)(_.walkInPct),detail:_.empty?void 0:`${_.walkIns} walk-in covers \xb7 ${_.bookings} booked covers \xb7 ${_.total} total`,change:(0,u.changeWords)((0,u.changePct)(_.walkInPct,O.walkInPct),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${oe}`,value:(0,u.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(B.rate,F.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${oe}`,value:(0,u.pctLabel)(A.rate),detail:A.empty?void 0:`${A.count} cancelled out of ${A.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(A.rate,H.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-covers",label:`Covers \xb7 ${oe}`,value:_.empty?null:String(_.total),detail:_.empty?void 0:'today'===D?V>0?`${V} more ${1===V?'cover':'covers'} booked for later today`:'No more bookings for later today':`${_.walkIns} walk-in \xb7 ${_.bookings} booked`,change:(0,u.changeWords)((0,u.changePct)(_.empty?null:_.total,O.empty?null:O.total),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${oe}`,value:(0,u.pctLabel)(ae.rate),detail:ae.empty?void 0:`${ae.count} of ${ae.of} identifiable seated or finished parties had visited before${te?` (visits on record from ${(0,u.ukDay)(te)})`:''}`,change:(0,u.changeWords)((0,u.changePct)(ae.rate,ne.rate),D),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(w,{testID:"insights-reviews",label:`Reviews \xb7 ${oe}`,value:ie.empty?null:`${ie.avg} / 5`,detail:ie.empty?void 0:`Average of ${ie.count} published review${1===ie.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(w,{testID:"insights-tips",label:`Tips (team total) \xb7 ${oe}`,value:(0,u.moneyGbp)((0,u.completeTotal)(J,J.tips)),detail:null==J.tips?void 0:N&&null!=se.pct?`${J.days} cash-up day${1===J.days?'':'s'} \xb7 ${(0,u.pctLabel)(se.pct)} of takings on the ${se.days} day${1===se.days?'':'s'} with takings`:`${J.days} cash-up day${1===J.days?'':'s'}`,change:J.missing||K.missing?null:(0,u.changeWords)((0,u.changePct)(J.tips,K.tips),D),empty:J.missing?(0,u.missingWords)(J.missing,'tips figure',J.missingDates):'No tips entered in this period'}),N?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(w,{testID:"insights-takings",label:`Takings \xb7 ${oe}`,value:(0,u.moneyGbp)(z.gross),detail:null==z.gross?void 0:`Card + cash \u2212 card tips, from ${z.days}${z.missing?` of ${z.days+z.missing}`:''} confirmed cash-up day${z.days+z.missing===1?'':'s'}${z.missing?`. ${(0,u.takingsMissingWords)(z.missingDates)}`:''}`,change:z.missing||U.missing?null:(0,u.changeWords)((0,u.changePct)(z.gross,U.gross),D),empty:z.missing?(0,u.missingWords)(z.missing,'card or cash total',z.missingDates):'No takings entered in this period'}),(0,f.jsx)(w,{testID:"insights-sph",label:`Spend per head \xb7 ${oe}`,value:(0,u.moneyGbp)(Y.sph),detail:null==Y.sph?void 0:`\xa3${Y.gross.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})} takings \xf7 ${Y.covers} seated or finished covers, on ${Y.days} day${1===Y.days?'':'s'} with both${Y.noCovers?`. ${Y.noCovers} day${1===Y.noCovers?'':'s'} with takings and no Covers (a function, say) count${1===Y.noCovers?'s':''} in takings, not here`:''}`,change:(0,u.changeWords)((0,u.changePct)(Y.sph,q.sph),D),empty:Y.noCovers?'Spend per head needs a day with both takings and seated or finished Covers':'No takings entered, so no spend per head'}),(0,f.jsx)(w,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${oe}`,value:(0,u.pctLabel)(Z.pct),detail:null!=Z.pct?`${(0,u.moneyGbp)(Z.labour)} signed-off wages \xf7 ${(0,u.moneyGbp)(Z.gross)} takings, on the ${Z.days} day${1===Z.days?'':'s'} with takings${z.missing?`. ${z.missing} cash up${1===z.missing?'':'s'} with no card or cash total left out`:''}${Z.awaiting?`. ${Z.awaiting} shift${1===Z.awaiting?'':'s'} on those days still need${1===Z.awaiting?'s':''} signing off, not counted yet`:''}`:void 0,change:(0,u.changeWords)((0,u.changePct)(Z.pct,ee.pct),D),empty:j||Object.keys(C).length?null==Z.gross?'Not enough data: no cash up in this period has a card or cash total':'Not enough data: no signed-off hours with a pay rate on the days with takings':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(o.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-not-shown",children:(0,f.jsx)(o.Muted,{center:!0,children:u.NOT_SHOWN_YET})})]})};var e,s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=(e=a)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),y=_r(d[10]),v=_r(d[11]),$=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function w({testID:e,label:s,value:t,detail:a,change:r,empty:l}){const c=!!r&&r.startsWith('Up'),h=!!r&&r.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.Muted,{center:!0,children:s}),null==t?(0,f.jsx)(o.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:l}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.T,{testID:`${e}-value`,weight:"semibold",size:y.font.hero,colour:y.colours.gold,center:!0,children:t}),a?(0,f.jsx)(o.Muted,{center:!0,children:a}):null,r?(0,f.jsx)(o.T,{testID:`${e}-change`,center:!0,colour:c?y.colours.goldLight:h?y.colours.muted:y.colours.text,children:r}):null]})]})})}},1507,[1465,17,85,777,858,1008,876,1055,1466,899,804,1241,1242,1057,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]})}},1508,[805,1418,812,822,843,1509,1437,1487,1227,841,1262,899,1510,1512,1438,17,1098,1495,13,385,85,864,1280,777,858,876,851,866,1105,1251,863,804,1183,1057,1139,869,1456,853,1026,1154,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)},1509,[843,17,85,777,845,851,1153,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)}}})]})}},1510,[899,17,264,219,85,1280,777,1259,1262,804,1511,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},1511,[17,219,85,777,1259,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'})})}},1512,[805,1418,17,85,777,851,1259,1260,1261,899,1262,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}),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'}]},1513,[812,891,779,869,1216,17,378,219,385,278,85,831,777,1098,858,876,1514,1518,804,1057,1071,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]}})})},1514,[1515,1517,1516]); -__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)}},1515,[843,1516]); -__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'}},1516,[]); -__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}},1517,[1515,1217]); -__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},1518,[869,824,831,834]); -__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})}},1519,[17,1211,1156,1212,1224,1057,1174,847,856,993,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'},1520,[17,85,777,899,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=v,_e.SmsBubble=C,_e.AlertSettings=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=(0,p.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,p.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,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,k.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,k.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>p.useAlerts.getState().setPrefs({muted:!e})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,y.chime)('bright')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,y.lowChime)(.6)})]}),(0,k.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,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,k.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),p.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindChip,{kind:e,size:30}),(0,k.jsx)(c.default,{style:{flex:1},children:(0,k.jsx)(h.Toggle,{label:p.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>p.useAlerts.getState().setType(e,s)})})]},e))]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,k.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,k.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,k.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${p.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,p.sendTestAlert)(s,e)},e))})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,k.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,k.jsx)(h.Muted,{children:r}),(0,k.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>p.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,k.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,p.requestSystemPermission)()),p.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,p.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,k.jsx)(h.Muted,{children:(0,p.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,k.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,k.jsx)(w.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindIcon,{kind:"email"}),(0,k.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,k.jsx)(h.Badge,{kind:"neutral",label:p.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,k.jsx)(h.Muted,{children:p.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${p.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,k.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,T.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,j.templatesFor)(r),[r]),p=(0,x.useAssistant)(e=>e.enabled)&&b.ASSISTANT_UI,[y,w]=(0,n.useState)('booking'),[A,M]=(0,n.useState)('sms'),B=u[y],I=s=>m.useStore.getState().setTemplate(e,y,s),R=Object.fromEntries(j.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===y?(0,j.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,j.bookingVars)({...S,date:o},s),N=(0,j.toGsm)((0,j.fill)(B.sms,L.sms)),_=(0,j.fill)(B.subject,L.email),D=(0,j.emailHtml)((0,j.fillEmailText)(B.body,L.email),{venue:s.name,preheader:_}),O=!!r?.[y],V=s.settings;return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:j.PREVIEW_BANNER}),(0,k.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,k.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(j.DEFAULT_TEMPLATES).map(e=>(0,k.jsx)(h.Chip,{label:j.TEMPLATE_LABEL[e].title,selected:y===e,onPress:()=>w(e)},e))}),(0,k.jsx)(h.Muted,{children:j.TEMPLATE_LABEL[y].when}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,k.jsxs)(h.Muted,{children:[(0,j.smsParts)(N).chars," characters"]})]}),(0,k.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:B.sms,onChangeText:e=>I({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,j.smsParts)(N).chars>300?(0,k.jsx)(h.T,{size:13,colour:f.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,k.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:B.subject,onChangeText:e=>I({subject:e}),style:h.styles.input}),(0,k.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,k.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:B.body,onChangeText:e=>I({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,k.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[p?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>I(P(B))}):null,O?(0,k.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,y,null)}):null]}),p?(0,k.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,k.jsxs)(h.Muted,{children:["Placeholders: ",j.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:"Text",selected:'sms'===A,onPress:()=>M('sms')}),(0,k.jsx)(h.Chip,{label:"Email",selected:'email'===A,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,k.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,k.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===y?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===A?(0,k.jsx)(C,{text:N,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),_]}),(0,k.jsx)(v,{html:D})]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,k.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,k.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:V.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,k.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!V.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,k.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,T.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),b=t.filter(e=>'all'===l||e.channel===l);return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:f.colours.gold,borderRadius:12,padding:12},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:f.colours.gold,children:(0,j.isLive)()?'Live: messages are sent through your text and email service.':j.PREVIEW_BANNER}),(0,j.isLive)()?null:(0,k.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,k.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,k.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),b.length?null:(0,k.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),b.map(e=>(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,k.jsxs)(h.T,{weight:"semibold",children:[A[e.kind]," \xb7 ",e.ref]})]}),(0,k.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,k.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,k.jsx)(h.T,{size:13,colour:'sent'===e.status?f.colours.ok:'failed'===e.status?f.colours.red:f.colours.amber,children:(0,j.statusLabel)(e)})]}),'sms'===e.channel?(0,k.jsx)(C,{text:e.body}):u===e.id?(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),e.subject]}),(0,k.jsx)(v,{html:e.html??'',height:560})]}):(0,k.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,k.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]),k=_r(d[18]);function v({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 C({text:e,to:t}){const l=(0,j.smsParts)(e);return(0,k.jsxs)(c.default,{style:{gap:4},children:[t?(0,k.jsxs)(h.Muted,{children:["To ",t]}):null,(0,k.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,k.jsx)(h.T,{size:15,children:e})}),(0,k.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const S={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 P(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 A={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1521,[813,812,822,17,219,385,85,777,1229,858,1518,1213,848,1231,1018,804,1027,1057,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:n,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,b=n.settings,x=(0,r.bookingRulesOf)(n),f=(0,o.usePlan)(g),j=(f?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...b.bookingRules??{},...x,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(n),M=(0,d.depositOf)(b),R=b.reservables??(0,i.reservablesOf)(n),O=(0,r.accessGuideOf)(n),[I,A]=(0,t.useState)(null),D=(e,t)=>T({largeGroups:x.largeGroups.map((n,s)=>s===e?{...n,...t}:n)});return(0,y.jsxs)(s.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."}),I?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:I}):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:b.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)(n)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(n)} 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."}),x.largeGroups.map((e,t)=>(0,y.jsxs)(s.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=>D(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>D(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=>D(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:x.largeGroups.filter((e,n)=>n!==t)})}):null]},t)),x.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=x.largeGroups[x.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...x.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:j.map(e=>{const t=x.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(x.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:x.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)(x,n.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(x.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(x.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:x.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!==b.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:x.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),x.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,x.onlineTableMins.map((e,t)=>(0,y.jsxs)(a.Muted,{center:!0,testID:`rules-table-min-${t}`,children:[(0,r.onlineTableMinLine)(e),". Staff can still book them for fewer."]},t)),(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:b.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:M.on&&M.perPersonPence>0?`${w(M.perPersonPence)} per adult for ${M.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),R.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:x.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:x.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:x.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:x.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:x.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:x.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}),A('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:n}=(0,k.useCtx)(6e4),o=T(n),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,b.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,f.isSupabaseConfigured)())return;let e=!0;try{(0,x.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:n})=>{e&&!n&&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)(s.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,f.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,x.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:j.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),n=_r(_d[1]),s=(e=n)&&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]),b=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),j=_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(b.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()},1522,[17,85,777,858,998,1079,1055,841,1105,1251,889,876,920,899,928,971,804,1057,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)})]})]})}},1523,[17,385,85,777,876,1000,851,1001,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]})}},1524,[17,219,385,85,409,777,804,1376,857,1380,863,899,1381,1057,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})},1525,[820,896,1454,17,219,85,777,816,876,895,1000,897,899,1526,804,880,1162,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'}},1526,[]); -__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])},1527,[17,85,777,804,1433,1509,1057,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=w,_e.HelpPage=function({go:e}){const[s,o]=(0,a.useState)(''),[r,h]=(0,a.useState)(null),[p,x]=(0,a.useState)(null),w=(0,a.useMemo)(()=>[...c.HELP,...m],[]),j=(0,a.useMemo)(()=>s.trim()?(0,u.searchHelp)(w,s,10).map(e=>e.a):w.filter(e=>!r||e.topic===r),[s,r,w]);return(0,f.jsxs)(i.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(i.default,{style:[l.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(l.T,{colour:y.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:o,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:y.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(n.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>o('')}):null]}),s?(0,f.jsx)(l.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)(l.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(l.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,n)=>(0,f.jsx)(b,{a:t,go:e,open:p===t.id||!!s&&0===n&&null===p,onToggle:()=>x(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(l.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",colour:y.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(l.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(l.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=function({go:e}){const{rid:t,today:s}=(0,x.useCtx)(6e4),n={rid:t,today:s,go:(t,s)=>e(t,s??null)},[o,r]=(0,a.useState)(''),[h,u]=(0,a.useState)(null),[m,b]=(0,a.useState)(null),C=async()=>{const e=o.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,n);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...j(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(i.default,{testID:"ask-assistant",children:(0,f.jsxs)(l.Card,{highlight:y.colours.gold,children:[(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(i.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(l.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:o,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:C,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(l.Button,{label:"Ask",testID:"assistant-ask",disabled:!o.trim(),onPress:C,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(l.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)(l.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(k,{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,n,!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,m?(0,f.jsxs)(i.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(l.Banner,{kind:'done'===m.kind?'success':'error'===m.kind?'warn':'demo'===m.kind?'demo':'info',title:m.text}),m.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>w(s,e)}):null]},t)})]}):null,(0,f.jsx)(l.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),o=e(_r(d[4])),i=e(_r(d[5])),l=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),y=_r(d[12]),x=_r(d[13]),f=_r(d[14]);const m=[{id:'ai-assistant-pairing',kind:'faq',topic:'Accounts',title:'Can I connect my own AI assistant?',keywords:['assistant','ai','pair','pairing','grok','bot','unpair','approve','draft','log'],body:'AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. In the connected assistant, it can answer questions about your venue and give advice from the venue data it is allowed to look up. It can draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged, including look-ups. Open More \u203a Account \u203a Assistants, as an owner, on Full Restaurant Pro, SuperPro or the early adopter offer. It is not included with Customer & Takeaway App, and there is no AI assistant on the Display app.',showMe:{tab:'more',page:'assistants',target:{testID:'assistants-page'},hint:'Pair, switch off or unpair an assistant here. Owners only.'}},{id:'customer-support',kind:'faq',topic:'Accounts',title:'How do I contact CoverCharge support?',keywords:['support','customer support','help','email','picture','photo','screenshot','contact','covercharge'],body:'Customer support is at the very bottom of Home, and at the bottom of More, as an owner. Write a message, attach one picture if you like (a photo or a screenshot), and tap Send to CoverCharge. It is sent with your venue name, your name and email, and the app version. You will see \u201cSent. We\u2019ll reply by email.\u201d if it went through, or an error with a way to try again. There is no Customer support on the Display, Staff, Front of House or Head Chef apps.',showMe:{tab:'more',page:'support',target:{testID:'customer-support'},hint:'Write a message, attach a picture if you like, and send it to CoverCharge. Owners only.'}},{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:'In the Managers app go to More \u203a Run the day \u203a Display settings 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. There is no wipe or unpair button on the Display itself. To switch a Display off, go to Settings \u203a Displays and choose Switch off.',showMe:{tab:'more',page:'displaysettings',target:{testID:'wipe-setting'},hint:'Sign out and wipe is in Display settings, in the Managers app only.'}}];function w(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 b({a:e,go:t,open:s,onToggle:n}){return(0,f.jsx)(i.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(o.default,{accessibilityRole:"button",onPress:n,children:(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(i.default,{style:{flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(l.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(l.T,{colour:y.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(i.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(l.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>w(e,t)})}):null]})})}function j(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function k({p:e,today:t,onChange:n,onConfirm:a,onCancel:o}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>n({...e.params,[t]:s}),x=e.action,m=e.params,w=x.params.every(e=>!e.required||void 0!==m[e.name]&&''!==m[e.name]);return(0,f.jsxs)(i.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?y.colours.red:y.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':y.colours.okBg},children:[(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[x.risk]}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:x.title})]}),x.form&&'add_walkin'===x.id?(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Covers",value:void 0===m.covers?'':String(m.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Table (optional)",value:void 0===m.table?'':String(m.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,x.form&&'add_rota_shift'===x.id?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{size:12,children:"Who"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(l.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:m.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1.3},children:(0,f.jsx)(l.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(m.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Start (24h)",value:String(m.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"End (24h)",value:String(m.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(l.T,{children:w?x.preview(m,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(l.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(l.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(l.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!w,onPress:a,style:{flex:1}}),(0,f.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:o,style:{flex:1}})]})]})}},1528,[812,1033,779,17,385,85,777,876,1479,1529,1530,1531,804,1057,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.','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:'guest-change-link',kind:'faq',topic:'Bookings',title:'Can guests change or cancel their own booking?',keywords:['change','cancel','link','email','guest','move','booking'],body:'Yes. The confirmation email has a "Change or cancel your booking" link for that one booking, with "Or call us on (your number) and quote your booking details." underneath. Guests can change the date, time or party size within your online booking rules, or cancel after confirming. Bookings with a deposit say "please call us" instead. Takeaway orders can\u2019t be changed or cancelled by the guest, and their email has no link. You see every change on the Display and in Managers, marked as changed by the guest. The link stops working at the booking time.'},{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:'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 takings \xf7 Covers, by day and by week. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). 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.'},{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.'}],o=t=>a.find(a=>a.id===t)},1529,[]); -__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}},1530,[]); -__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}},1531,[1532,1100,843,1533,1534,876,858,998,1479,1529,1530,1536,1535,1538,1539,996,997]); -__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))}}]},1532,[1064,1063,1023]); -__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.`)}}]},1533,[896,1100,820,843,1121,1098,1115,922,858,816,998,895,897,1010,876,1067,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]),n=_r(_d[3]),r=_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)=>r.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(),n=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(n){const e=Number(/\d/.test(n[1])?n[1]:n[2]),a=L.indexOf(/\d/.test(n[1])?n[2]:n[1]);let r=Number(t.slice(0,4));return`${r}-${A(a+1)}-${A(e)}`e.active)){const n=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),r=Math.min(...n.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));r<1/0&&a.push({s:e,at:r})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>r.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(),n=U(e);if(!n.length)return;const r=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(r)return n.find(e=>e.number===Number(r[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=n.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===n.length?n[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const r=a.useStore.getState(),i=r.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=n.useFloor.getState(),c=d.plans[e]??(0,n.seedPlan)(e),h=r.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,r.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 n=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return n?`Seat ${Y(a)}, at table ${n}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const r=z(a.rid,e.who);if(!r)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,r.partySize);return i?(await t.repo.waitlist.setStatus(r.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,r.partySize,i,`From waitlist #${r.number}`),(0,n.tablesOf)(i).forEach(e=>n.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${r.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=r.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),n=j(String(t??''),e.today);return n?a.find(e=>e.date===n):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(),n=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(n){const e=j(n[1],t),a=j(n[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!n||e.kind===n)),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 ne(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),n=new Date(a+'T00:00:00').getTime(),r=n+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=n&&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>=n&&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)()),n=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),r=(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=>r.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),n):[];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 n;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(n?.s??0)&&(n={m:t,s:e})}return n?.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 n=z(a.rid,e.who);return n?(await t.repo.waitlist.setStatus(n.id,'removed'),`Done: number ${n.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,r)=>{const i=z(r.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===r.rid);return n.useFloor.getState().logSms(r.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?r.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(r.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),n=E(e.with);return n&&n.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(n.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),n=E(e.with);return a&&t.whoId?n&&n.id!==t.whoId?(r.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:n.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(n.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)())),n=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:n&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(n[1])?n[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=r.useOwner.getState().shifts.find(e=>e.id===t.shiftId),n=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${n}\u2019s swap with ${i}`:t.toId?`${i} covering ${n}`:`${n}\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 ${n}\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=r.useOwner.getState(),n=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)}${n?` (${M[n.day]} ${R(n.start)}\u2013${R(n.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 n=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: ${n.n} checks, ${n.bad} out of range${n.bad?`, ${n.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:n}=ne(t.today,t),r=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(r)return`This week is already signed off by ${r.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${n.entries} checks, ${n.outOfRange} out of range, ${n.actions} with an action, diary signed ${n.daysSigned} of 7 days.`;return n.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:n}=ne(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':n.actions!0),note:'Signed by voice: yes to all.',summary:n}),'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),n=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${n}; 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)),n='Near miss'===a.category,r=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(r)}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??'')||(n?'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:n,rem:r}=se(t,e.task);return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?`${_(n.text)} is already ticked today.`:`Tick off today\u2019s task ${_(n.text)}?`:r?`Mark the reminder ${_(r.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:n,rem:r}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,n.id,a,i),`Done: ${_(n.text)} ticked.`):r?(c.useReminders.getState().markDone({rid:t.rid,reminderId:r.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),r=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=n?.sections.find(e=>r.includes(e.toLowerCase())||r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=String(e.section??n?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${r} 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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(r)||r<=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??n?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:r,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 n=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 n?{dish:n[1],field:'description',value:n[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 n=de(t.rid,e.dish),r=String(e.value??'').trim();return n?r.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(n.id,'name'===e.field?{name:r}:{description:r}),'name'===e.field?`Done: renamed to ${r}.`:`Done: description of ${n.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 n=(0,$.findCard)(t.rid,a.dish);return n?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${n.dish}\u2019s recipe card?${n.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)),n=a&&(0,$.findCard)(t.rid,a.dish);return a&&n?(await(0,y.recipeCards)().update(n.id,{ingredients:[...n.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 ${n.dish}.${n.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,n=String(e.step??'').trim();return!a||n.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,n]},{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],n=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),r=/\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:r,reason:n?.[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 n=e.action??'in',r=(0,g.managerClockAction)(n,{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 r.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[n]} at ${D()}.${r.warn?' '+r.warn:''}`:'Nothing changed: '+r.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 n=h.useCashUp.getState(),r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,r?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(n.tips.filter(e=>e.rid===t.rid),n.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: 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 n='yesterday'===e.day?(0,l.ymdOf)(a):e.day,r=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!n||e.date===n)).sort((e,t)=>t.date.localeCompare(e.date)),i=r[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: takings ${fe((0,p.tillTakingsOf)(i.vals))} (card + cash \u2212 card tips), tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:n?`There\u2019s no cash-up for ${(0,$.niceDay)(n)}.`:'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 r='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,n.tablesOf)(a).forEach(e=>n.useFloor.getState().setLive(t.rid,e,{note:r||void 0})),r?`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 n=(0,$.appNow)();return r.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(n)} ${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',n=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),r=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:n?.[1]?.trim(),time:r?(0,$.hm)(r[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??''),n=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(n)}, ${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(),n=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(n))return'Nothing changed: I need the wording and a time like 21:00.';const r=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:r,time:n,audience:e.audience??'all'}),'Done: reminder added.'}}]},1534,[820,858,816,998,876,1003,1014,1015,927,926,1008,839,1034,1035,1036,1004,1067,867,1076,995,854,1535,1533]); -__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.'}}]},1535,[820,891,1100,843,1140,1262,858,816,998,1003,910,846,845,1076,1077,995,1004,851,1536,1537]); -__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)}))},1536,[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)}))},1537,[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)])},1538,[816,876,910,851,1535,1017,1071]); -__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))'},1539,[]); -__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,u.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:u.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:u.VOICE_ROLE_LABEL[s],value:(0,u.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,h.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:p}=(0,f.useCtx)(6e4),u=(0,r.useDrafts)(e=>e.drafts),h=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=u.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),D='owner'===p||'manager'===p,C=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:r.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&&D?(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'})}),C(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${C(e).name} ordering`,onPress:()=>{t.default.openURL(C(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:"Drafts saved earlier (bookings, supplier shopping lists, offers, events, specials, messages and payments) wait 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."}),D?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:()=>{h(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,p.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,p.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. 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]),r=_r(_d[6]),l=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),h=_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'}}},1540,[17,362,85,777,804,1475,1536,1487,1537,1541,1216,1542,1057,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return s}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(f(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(f(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),s=(e,n,t)=>!1!==e[n]?.[t],f=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1541,[824,831,834]); -__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])},1542,[17,85,777,804,1543,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.'},1543,[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}},1544,[17,779,85,777,845,1259,1545,1546,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'},1545,[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()})},1546,[899,1545,1262]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:l,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,o.useCashUp)(e=>e.cashUps),k=(0,o.useCashSettings)(e),w=(0,d.useNightlyPrefs)(s=>s.email[e]??!1),T=(0,d.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(s=>s.rid===e&&s.on).map(e=>e.name),[N,U]=(0,s.useState)((0,u.addDaysYmd)(v,-1)),P=(0,u.cashFieldsForRecord)(k.cashFields,(0,u.cashUpRecordFor)(e,l.settings.cashUpRecord)),R=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:P,soldOut:C}),_='anchorage'!==e&&w,D=[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:D.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:()=>U(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:R.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(R.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(R.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(R.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:R.takings}),(0,j.jsx)(x,{label:"Tips",value:R.tips}),(0,j.jsx)(x,{label:"Takings last week",value:R.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:R.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:R.soldOut.length?R.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),R.cashUp.length?R.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:_,onChange:s=>T(e,s)}):null]})};var e,s=_r(_d[0]),l=_r(_d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),d=_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:s})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${s}`,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:s})]})},1547,[17,85,777,858,1008,1548,891,839,1549,1020,804,1057,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}))},1548,[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.tillTakingsOf)(k.vals):null,N=(0,l.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:s(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(y),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(O?(0,t.tillTakingsOf)(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]),l=r(d[2]);const s=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?s(t):String(t);function u(t,l,u){const c=[];for(const f of l){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const l=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==l?'Not entered':s(l)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!l.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const l=(0,n.expectedCashInDrawer)(t);null!=l&&c.push({label:'Expected cash in the drawer',value:s(l)})}return c}},1549,[839,1009,1467]); -__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.SupportChatPage=function(){const{r:e,me:f,meId:x}=(0,h.useCtx)(6e4),[j,v]=(0,s.useState)(''),[C,I]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[R,D]=(0,s.useState)('idle'),[L,P]=(0,s.useState)(''),[k,B]=(0,s.useState)(''),[_,T]=(0,s.useState)('');(0,s.useEffect)(()=>{(0,p.signedInEmail)().then(B)},[]);const E=async e=>{T('');try{const t=await(0,c.capturePlatingPhoto)(e);t&&(I(t),D(e=>'sent'===e?'idle':e))}catch(e){T(e instanceof Error?e.message:'Could not add that picture.')}},H=async()=>{const t=j.trim();if(!t||w)return;S(!0),P(''),D('idle');const s=await(0,p.writeSupportRequest)({venueName:e.name,body:t,fromName:f.replace(' (example)',''),fromEmail:k,staffRef:x||'',appVersion:u.APP_VERSION,photoDataUrl:C?.dataUrl??null});if(S(!1),s.ok)return v(''),I(null),D('sent'),void P(b);D('error'),P(s.message)};return(0,y.jsxs)(l.default,{testID:"customer-support",style:{gap:12,alignItems:'center',width:'100%',paddingBottom:8},children:[(0,y.jsx)(o.T,{center:!0,weight:"bold",colour:n.colours.gold,accessibilityRole:"header",children:"Customer support"}),(0,y.jsx)(o.Muted,{center:!0,children:"Send a message to CoverCharge. You can attach one picture, such as a photo or a screenshot. We'll reply by email."}),'sent'===R?(0,y.jsx)(l.default,{testID:"support-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:b,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"success",title:b})}):null,'error'===R?(0,y.jsx)(l.default,{testID:"support-error",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:L,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"danger",title:L})}):null,(0,y.jsx)(t.TextInput,{testID:"support-message",accessibilityLabel:"Your message to CoverCharge",value:j,onChangeText:e=>{v(e),'sent'===R&&D('idle')},placeholder:"Write your message",placeholderTextColor:n.colours.muted,multiline:!0,style:{width:'100%',minHeight:120,borderWidth:1,borderColor:n.colours.border,borderRadius:12,padding:12,color:n.colours.text,textAlign:'center'}}),C?(0,y.jsxs)(l.default,{testID:"support-photo-preview",style:{alignItems:'center',width:'100%',gap:8},children:[(0,y.jsx)(r.default,{source:{uri:C.dataUrl},style:{width:240,height:180,borderRadius:12,backgroundColor:n.colours.surface2},accessibilityLabel:"Attached picture preview"}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Remove picture",accessibilityLabel:"Remove the attached picture",testID:"support-photo-remove",onPress:()=>I(null),style:{minHeight:48}})]}):(0,y.jsxs)(l.default,{style:{width:'100%',gap:8,alignItems:'center'},children:[(0,y.jsx)(o.Button,{kind:"secondary",label:"Take a photo",accessibilityLabel:"Take a photo to attach",testID:"support-photo-camera",onPress:()=>{E('camera')},style:{minHeight:48,width:'100%'}}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a picture or screenshot from your gallery",testID:"support-photo-gallery",onPress:()=>{E('library')},style:{minHeight:48,width:'100%'}})]}),_?(0,y.jsx)(o.Muted,{center:!0,testID:"support-photo-error",children:_}):null,(0,y.jsx)(o.Button,{testID:"support-send",label:"Send to CoverCharge",accessibilityLabel:"Send to CoverCharge",disabled:!j.trim()||w,onPress:()=>{H()},style:{minHeight:56,width:'100%'}}),w?(0,y.jsx)(l.default,{accessibilityLiveRegion:"polite",style:{width:'100%'},children:(0,y.jsx)(o.Muted,{center:!0,testID:"support-sending",children:"Sending\u2026"})}):null]})};var t=_r(d[0]),s=_r(d[1]),r=e(_r(d[2])),l=e(_r(d[3])),o=_r(d[4]),n=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),y=_r(d[10]);const b="Sent. We'll reply by email."},1550,[812,17,319,85,777,804,1082,978,1551,1057,8]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPPORT_BUCKET",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SUPPORT_SEND_FAILED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SUPPORT_SIGN_IN",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SUPPORT_NO_EMAIL",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SUPPORT_PHOTO_FAILED",{enumerable:!0,get:function(){return l}}),e.writeSupportMessage=async function(o){if(!t.RELEASE.supportSync)return{ok:!1,message:n.SUPPORT_NOT_SENT};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:n.SUPPORT_NOT_SENT};const c=u.useSync.getState().venueId;if(!c)return{ok:!1,message:`${n.SUPPORT_NOT_SENT} Sign in and try again.`};try{const t=(0,i.getSupabase)(),{error:s}=await t.from('support_messages').insert({venue_id:c,body:o.text,from_name:o.from,staff_ref:o.staffRef||null});return s?{ok:!1,message:n.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:n.SUPPORT_NOT_SENT}}},e.writeSupportRequest=async function(t){if('undefined'!=typeof globalThis&&globalThis.__CC_SUPPORT_FAKE_SEND)return{ok:!0,id:'preview-test',emailed:!0};const n=t.body.trim().slice(0,4e3),S=t.fromName.trim().slice(0,80),y=t.fromEmail.trim().slice(0,254),P=t.venueName.trim().slice(0,120);if(!n||!S||!P)return{ok:!1,message:f};if(!y||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y))return{ok:!1,message:m};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:p};const b=u.useSync.getState().venueId;if(!b)return{ok:!1,message:p};const T=globalThis.crypto?.randomUUID?.()??`00000000-0000-4000-8000-${Date.now().toString(16).padStart(12,'0')}`,O=(0,i.getSupabase)();let h=null;if(t.photoDataUrl)try{const n=_(t.photoDataUrl);h=`${b}/${T}.jpg`;const{error:o}=await O.storage.from(c).upload(h,n,{contentType:'image/jpeg',upsert:!1});if(o)return{ok:!1,message:l}}catch{return{ok:!1,message:l}}const E={id:T,venue_id:b,venue_name:P,body:n,from_name:S,from_email:y,staff_ref:t.staffRef||null,app_version:(t.appVersion||o.APP_VERSION).slice(0,40),photo_path:h},{error:N}=await O.from('support_requests').insert(E);if(N)return{ok:!1,message:f};let U=!1;try{const t=await O.functions.invoke('send-support-email',{body:{request_id:T}}),n=t.data;U=!t.error&&!!n?.sent}catch{U=!1}return{ok:!0,id:T,emailed:U}},e.signedInEmail=async function(){if(!(0,s.isSupabaseConfigured)())return'';try{const{data:t}=await(0,i.getSupabase)().auth.getUser();return(t.user?.email??'').trim()}catch{return''}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),i=r(d[4]),u=r(d[5]);const c='support-photos',f='Could not send. Check your connection and try again.',p='Could not send. Sign in and try again.',m='Your sign-in has no email. Sign in again and try again.',l='Could not attach the picture. Try a smaller photo, or send without a picture.';function _(t){const n=/^data:([^;]+);base64,(.+)$/.exec(t);if(!n)throw new Error('bad picture');const o=atob(n[2]),s=new Uint8Array(o.length);for(let t=0;t{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{}}},1552,[17,264,219,85,777,812,804,899,1428,1187,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+'},1553,[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 ']]},1555,[]); -__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:te,height:se}=(0,a.default)(),[oe,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(!1),[le,ae]=(0,t.useState)(!1),[de,ce]=(0,t.useState)(''),[ue,ge]=(0,t.useState)(!1),[he,pe]=(0,t.useState)(!1),[be,fe]=(0,t.useState)(!1),[me,xe]=(0,t.useState)(!1),ke=(0,t.useRef)(null),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(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,M.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const Ce=(0,K.useTakingsAllowed)(s),ve=(0,t.useCallback)(e=>{const t=(0,A.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),De=(0,t.useMemo)(()=>(0,V.buttonsFor)({takings:Ce,pageOk:ve}),[Ce,ve]),Ie=oe?(0,V.tabsFor)(oe.btn,{takings:Ce,pageOk:ve}):[],Se=(0,t.useCallback)((e,t)=>{const s=(0,V.tabsFor)(e,{takings:Ce,pageOk:ve});s.length&&(ie(!1),ae(!1),ce(''),ne({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[Ce,ve]),Te=De.find(e=>'settings'===e.id),Re=(0,t.useCallback)(e=>{const t=De.find(t=>t.pages.some(t=>t.id===e));t?Se(t,e):Te&&ve(e)&&(ie(!1),ae(!1),ce(''),ne({btn:Te,tab:'@desk-settings',page:e}))},[De,Se,Te,ve]),Oe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Re(t);else{if('bookings'===e){const e=De.find(e=>'bookings'===e.id);return void(e&&Se(e,'@bookings'))}if('chat'===e){const e=De.find(e=>'chat'===e.id);return void(e&&Se(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Te&&Se(Te):ne(t=>({btn:t?.btn??De[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else ne(null)},[De,Se,Re,Te]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Oe}),()=>T.useVoiceNav.setState({go:null})),[Oe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Oe('bookings'):'chat'===e?Oe('chat'):Oe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Pe=!oe||De.some(e=>e.id===oe.btn.id)&&Ie.some(e=>e.id===oe.tab)&&(!oe.page||ve(oe.page));(0,t.useEffect)(()=>{if(!Pe){const e=setTimeout(()=>ne(null),0);return()=>clearTimeout(e)}},[Pe]);const Le=oe?.page?(0,A.pageFor)(oe.page):void 0,We=oe?(0,_.deskCopy)(Le?.title??oe.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${We} \xb7 The Anchorage \xb7 CoverCharge for desktop`),we.current?.scrollTo?.({y:0,animated:!1}),oe){const e=setTimeout(()=>Y(je.current),80);return()=>clearTimeout(e)}},[We,oe?.tab,oe?.page]),(0,t.useEffect)(()=>{if(le){const e=setTimeout(()=>ke.current?.focus?.(),100);return()=>clearTimeout(e)}},[le]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=q(e.target),s=(0,_.commandKey)(e,t);if('escape'===s){if(le||ue||he||be)return e.preventDefault(),ae(!1),ge(!1),pe(!1),void fe(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return re?(e.preventDefault(),void ie(!1)):void(oe&&(e.preventDefault(),ne(null)))}if(le||ue||he||be||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),ie(!1),void ae(!0);if('help'===s)return e.preventDefault(),void ge(!0);if('filter'===s&&ye.current&&oe)return e.preventDefault(),void ye.current?.focus?.();const o=t?null:(0,_.shortcutIndex)(e);null!=o&&De[o]&&(e.preventDefault(),Se(De[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[le,ue,he,be,re,oe,De,Se]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Oe,globalThis.__deskOpen=(e,t)=>{const s=De.find(t=>t.id===e);s&&Se(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Oe,De,Se]);const Be=(0,t.useMemo)(()=>{const e=de.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De.flatMap(e=>(0,V.tabsFor)(e,{takings:Ce,pageOk:ve}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Se(e,t.id)}))),o=new Set(De.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...A.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,_.deskCopy)(e.title),sub:(0,_.deskCopy)(e.sub??''),run:()=>Re(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[de,De,s,Ce,ve,Se,Re]),He=(0,N.ddmmyyyy)(o),Me=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),Ee=b?(0,B.authorityRole)(b):s,$e=(b?.name??h).replace(' (example)',''),ze='owner'===Ee?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Ae=e=>(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Fe=e=>{const t=(0,A.pageFor)(e);return!t||t.can&&!t.can(s)?(0,X.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,X.jsx)(t.C,{go:Oe})})};return(0,X.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,X.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>oe?Y(je.current):ie(!0),children:(0,X.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:oe?'Skip to main content':'Open the owner tools menu'})}),(0,X.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,X.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:te,headerExtra:(0,X.jsx)(J,{open:re,onPress:()=>ie(!0)}),subHeader:(0,X.jsx)(Q,{name:$e,access:ze,day:He,at:Me})}),oe&&Pe?(0,X.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,X.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,X.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,X.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:oe.page?'Back to all settings':`Close ${oe.btn.label}, back to the floor plan`,onPress:()=>oe.page?ne({...oe,page:null}):ne(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,X.jsx)(f.T,{weight:"semibold",center:!0,children:oe.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,X.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,X.jsx)(l.default,{ref:je,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,X.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:We})}),(0,X.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,_.deskCopy)(Le?.sub??oe.btn.hint)})]}),(0,X.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,X.jsx)(J,{testID:"desk-menu-button-page",open:re,onPress:()=>ie(!0)})})]}),Ie.length>1&&!oe.page?(0,X.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Ie.map(e=>{const t=e.id===oe.tab;return(0,X.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>ne({btn:oe.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?Z:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,X.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,X.jsx)(i.default,{ref:we,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(!oe||!Pe)return null;if(oe.page)return Fe(oe.page);switch(oe.tab){case'@desk-bookings':return(0,X.jsx)(K.DesktopBookings,{filterRef:ye});case'@desk-hours':return(0,X.jsx)(K.DesktopHours,{go:Oe,filterRef:ye});case'@desk-takings':return Ce?(0,X.jsx)(K.DesktopTakings,{go:Oe}):(0,X.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,X.jsx)(K.DesktopSettings,{open:e=>ne(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,X.jsx)(G.DeskPermissions,{});case'@desk-leavers':return(0,X.jsx)(G.DeskLeavers,{});case'@desk-temps':return Ae((0,X.jsx)(G.DeskTemps,{}));case'@desk-bookinghistory':return Ae((0,X.jsx)(G.DeskCoversHistory,{}));case'@bookings':return(0,X.jsx)(H.Bookings,{go:Oe});case'@chat':return(0,X.jsx)(M.Chat,{go:Oe});case'@noshows':return Ae((0,X.jsx)(W.NoShows,{go:Oe}));case'@orders':return(0,X.jsx)($.Orders,{});case'@forecast':return(0,X.jsx)(E.Forecasts,{go:Oe});default:return Fe(oe.tab)}})()})]}):null]}),(0,X.jsx)(ee,{visible:re,buttons:De,current:oe?.btn.id,W:te,H:se,onClose:()=>ie(!1),onPick:e=>Se(e),onFind:()=>{ie(!1),ae(!0)},onKeys:()=>{ie(!1),ge(!0)},onInstall:()=>{ie(!1),pe(!0)},onSignOut:()=>{ie(!1),fe(!0)}}),le?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ae(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,X.jsx)(p.TextInput,{ref:ke,value:de,onChangeText:ce,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,X.jsx)(l.default,{'aria-live':'polite',children:(0,X.jsxs)(f.Muted,{center:!0,children:[Be.length," pages"]})}),Be.slice(0,60).map(e=>(0,X.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,X.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,X.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ue?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ge(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,_.SHORTCUTS)((0,F.isMac)()).map(([e,t])=>(0,X.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,X.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,X.jsx)(f.T,{center:!0,children:t})]},e)),(0,X.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,be?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>fe(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,X.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,X.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,X.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>fe(!1),testID:"desk-signout-cancel"}),(0,X.jsx)(f.Button,{label:me?'Signing out\u2026':'Sign out',disabled:me,onPress:async()=>{xe(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,he?(0,X.jsx)(f.Sheet,{visible:!0,onClose:()=>pe(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,X.jsx)(U.DesktopInstallPage,{})}):null,(0,X.jsx)(k.SeatAllergenReminder,{rid:e}),(0,X.jsx)(x.PrintHost,{rid:e}),(0,X.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Oe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,X.jsx)(z.OnboardingHost,{go:Oe}),(0,X.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]);r(d[37]);var F=r(d[38]),_=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]);const q=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Y=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},Z='rgba(201,162,74,0.14)';function J({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,X.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,X.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,X.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,X.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function Q({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,X.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,X.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,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function ee({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,V.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(()=>Y(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,F.isMac)();return(0,X.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,X.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,X.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,X.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,X.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,X.jsx)(l.default,{style:{width:56}}),(0,X.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,X.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,X.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,X.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,V.deskShortcut)(t,B);return(0,X.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,X.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:Z,alignItems:'center',justifyContent:'center'},children:(0,X.jsx)(G.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,X.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,X.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,X.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1556,[17,266,347,219,385,278,85,409,19,780,812,779,777,1229,1392,1087,1479,1086,1084,1231,1244,891,876,1032,1487,880,899,804,1339,1557,1057,1417,1160,1481,1483,1472,1456,1485,1553,1555,1563,1564,1565,1568,1571,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))}},1557,[17,266,347,219,385,278,85,409,780,779,1339,1456,1485,1417,1160,1483,1481,1057,1026,777,858,876,863,899,880,804,1558,1559,1560,1561,1562,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1558,[]); -__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])},1559,[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])},1560,[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])},1561,[17,385,1162,1163,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},1562,[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,b=Math.round(1.4*h),k=Math.max(48,Math.min(72,c-2*b-14,l-34));return{panelW:n,colW:l,per:c,circle:k,label:h,lineH:b,icon:Math.round(.44*k),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}],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'},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','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}`},1563,[1558]); -__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)},1564,[]); -__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,f.useOwner)(e=>e.staff),x=(0,f.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)),T=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=T.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,f.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,D.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,m.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,D.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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,D.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,D.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,f]=(0,t.useState)('next7'),[m,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[T,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,D.bookingColumns)(T),[T]),E=(0,t.useMemo)(()=>(0,D.sortRows)((0,D.filterRows)((0,D.bookingsBetween)(r,W,L,m),z,x),z.find(e=>e.key===$),M),[r,W,L,m,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:()=>f(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:m===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:T?'Hide phone numbers':'Show phone numbers',selected:T,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,D.csvName)('bookings',W,L),(0,D.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,D.ddmmyyyy)(W)}${L!==W?` to ${(0,D.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,D.ddmmyyyy)(W)} to ${(0,D.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,D.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${D.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,D.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",D.STATUS_WORD[G.status]??G.status]}),G.phone&&T?(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,f.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,m]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,T]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,f.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,D.ukTime)(e.in),outT:(0,D.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,D.sortRows)((0,D.filterRows)(O.filter(e=>'all'===p||e.status===p),D.HOURS_COLUMNS,y),D.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:m,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,D.csvName)('hours',R,M),(0,D.toCsv)(N,D.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,D.hm)((0,D.totalPaid)(N))} paid \xb7 ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`,cols:D.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(T(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,D.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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:T.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...T.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!T.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,T.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,T.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,T.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]),f=_r(_d[13]),m=_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]),T=_r(_d[23]),D=_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 f.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]}},1565,[17,385,85,409,812,777,1072,1032,1179,1122,1091,858,1008,876,1055,839,889,899,804,1417,1057,1456,1566,1555,1564,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}),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},1566,[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)}.`}},1567,[17,85,780,777,804,1566,1564,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}]},1568,[17,264,385,85,780,777,858,876,1569,915,1214,1463,804,1559,1057,1566,1570,1564,1567,1565,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)}))},1569,[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)},1570,[915]); -__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))})]})}},1571,[17,85,777,804,1572,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)},1572,[]); -__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:h,today:O,now:I,meId:N,me:X}=(0,A.useCtx)(3e4);(0,x.useTipsPosted)(e,O);const Z=(0,A.useSignedIn)();(0,m.useSoldOutLink)(!0,(Z?.name??X).replace(' (example)',''));const[q,J]=(0,s.useState)({kind:'tab',tab:'home'}),[Q,Y]=(0,s.useState)(''),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,A.ensureAttendance)(O,I),(0,D.ensureChat)(I)},[O]),globalThis.__ccNow=I.getTime();const te=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=V[t];return void J(e?{kind:'edit',id:e}:{kind:'page',id:t})}J('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:te}),()=>C.useVoiceNav.setState({go:null})),[te]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=te,globalThis.__deskGo=e=>J(e))},[te]),(0,v.useAlertWatcher)(e,{nag:'staff'!==h}),(0,w.useScheduledNotices)({rid:e,staffId:Z?.id??'',name:X,onOpen:e=>'bookings'===e?te('bookings'):'chat'===e?te('chat'):te('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==h&&!!Z});const ae=(0,s.useMemo)(()=>[...$,...F].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 ee.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=ae[Number(e.key)-1];return void(t&&(e.preventDefault(),J(t)))}if('z'===t&&!U(e.target)){const t=(0,z.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!U(e.target)){const t=(0,z.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae]);const se=B.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(h))&&!V[e.id]),ne=(0,s.useMemo)(()=>{const e=Q.trim().toLowerCase(),t={};return se.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[se,Q]),oe=$.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(h)),re=p.CAN.forecasts(h)?F:F.filter(e=>'rota'===e.s.id),ie='page'===q.kind?(0,B.pageFor)(q.id):void 0,le='tab'===q.kind?$.find(e=>K(e.s,q))?.label:'edit'===q.kind?F.find(e=>K(e.s,q))?.label:ie?.title,de='tab'===q.kind?$.find(e=>K(e.s,q))?.tip:'page'===q.kind?`${ie?.sub??''}. Press ${(0,_.CMD)()}K to jump to any page.`:'',ue=({label:e,s:t,n:a})=>{const s=K(t,q);return(0,W.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>J(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,W.jsx)(f.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,W.jsxs)(f.T,{size:11,colour:S.colours.muted,children:[(0,_.CMD)(),a]}):null]})},ce=({t:e})=>(0,W.jsx)(f.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),be='owner'===h?'OWNER':'manager'===h?'MANAGER':'STAFF';return(0,W.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,W.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,W.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(f.Row,{gap:10,children:[(0,W.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(u.VenueName,{name:c.name}),(0,W.jsx)(f.Row,{gap:6,children:(0,W.jsx)(l.AppBadge,{label:be})})]})]}),(0,W.jsx)(u.PoweredBy,{}),(0,W.jsx)(a.TextInput,{ref:ee,testID:"side-filter",value:Q,onChangeText:Y,placeholder:`Find a page (${(0,_.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[f.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,W.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Q?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{t:"Run the day"}),oe.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:t+1},e.label)),(0,W.jsx)(ce,{t:"Drag-and-drop editors"}),re.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:oe.length+t+1},e.label))]}),Object.entries(ne).map(([e,t])=>(0,W.jsxs)(r.default,{children:[(0,W.jsx)(ce,{t:e}),t.map(e=>(0,W.jsx)(ue,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,W.jsxs)(r.default,{style:{flex:1},children:[(0,W.jsx)(r.default,{testID:"desk-title",children:(0,W.jsx)(f.T,{size:24,weight:"bold",children:le??''})}),(0,W.jsxs)(f.Muted,{size:12,children:[Z?`Signed in as ${Z.name} \xb7 ${p.ROLE_LABEL[h]}`:`Preview \xb7 ${p.ROLE_LABEL[h]}`," \xb7 ",c.name]})]})}),(0,W.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[de?(0,W.jsx)(H.Tip,{children:de}):null,'edit'===q.kind?(0,W.jsx)(G,{id:q.id,rid:e,me:X,role:'owner'===h?'owner':'manager',today:O,venue:c.name}):(0,W.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===q.kind&&'home'===q.tab?(0,W.jsx)(L.Dashboard,{go:te}):null,'tab'===q.kind&&'orders'===q.tab?(0,W.jsx)(P.Orders,{}):null,'tab'===q.kind&&'bookings'===q.tab?(0,W.jsx)(E.Bookings,{}):null,'tab'===q.kind&&'forecast'===q.tab?(0,W.jsx)(R.Forecasts,{go:te}):null,'tab'===q.kind&&'chat'===q.tab?(0,W.jsx)(D.Chat,{go:te}):null,ie?(0,W.jsx)(ie.C,{go:te}):'page'===q.kind?(0,W.jsx)(f.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,W.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==h?(0,W.jsx)(g.PrintHost,{rid:e}):null,'staff'!==h?(0,W.jsx)(b.AlertHost,{variant:"managers",rid:e,me:X,onOpen:e=>te('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,W.jsx)(M.OnboardingHost,{go:te}),(0,W.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]),f=_r(d[12]),h=_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]);_r(d[33]);var O=_r(d[34]),_=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]);const $=[{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.'}],F=[{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:''}],V={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},K=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),U=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function G({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,h.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,W.jsx)(I.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,W.jsx)(N.RotaEditor,{today:o}):'brand'===e?(0,W.jsx)(O.BrandEditor,{rid:t}):(0,W.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,W.jsxs)(H.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,_.CMD)(),"Z undoes, then Save."]}),g?(0,W.jsx)(f.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,W.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,W.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{h.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)})]})}},1573,[813,812,17,385,278,85,19,1362,857,1365,1229,1392,777,998,876,891,1032,1479,1087,1086,1084,1487,1231,880,804,1417,1160,1057,1430,1481,1472,1483,1456,1485,1574,1553,1576,1578,1580,1577,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])},1574,[17,278,85,1500,857,777,876,814,1457,804,1575,1576,1577,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)})},1575,[]); -__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},1576,[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})},1577,[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."})]})]})}},1578,[812,17,85,777,860,816,891,893,894,845,867,1152,804,1575,1576,1577,1579,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])},1579,[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)}`},1580,[17,85,777,876,1060,804,1575,1576,1577,1051,1579,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]})}},1581,[13,17,856,1582,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)','')}})}},1582,[1457,1583,813,912,1072,1509,1208,1209,1028,1025,1026,1510,1544,1512,1152,891,978,1584,975,880,1031,1032,1493,914,1008,915,17,1154,1240,1244,1202,356,385,278,85,409,19,777,857,876,804,1160,1417,1066,1084,1086,1081,1027,1010,1057,1503,1498,1525,1585,1425,920,219,1245,1181,1187,1455,1201,1198,1480,1184,878,1211,1212,884,776,899,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']]},1583,[17,85,777,1057,899,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}},1584,[219,976]); -__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)','')},1585,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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]})}},1586,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1587,[1450,899,778,1411,1588,995,13,1615,479,17,368,319,219,24,85,805,857,1065,856,1617,19,858,998,876,804,1425,920,988,1618,1619,1028,1104,880,1008,914,1621,1381,8,1622,1623,1624,1625]); -__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])},1588,[1589,1612,1614]); -__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)}}},1589,[198,1590,1593,1607,1608,1609,1610,1611]); -__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}},1590,[198,1591]); -__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}},1591,[1592]); -__d(function(g,r,i,a,m,e,d){},1592,[]); -__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)}},1593,[1594,198,1590,1607,1608]); -__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]}})})},1594,[1595,1596,1606]); -__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()}})}},1595,[1596,1600,1605]); -__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}}},1596,[198,355,1597,1601,1602,1603,1604,1600,1605]); -__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}},1597,[198,1598,322,263,1599,1600]); -__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])},1598,[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}}},1599,[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},1600,[]); -__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}},1601,[]); -__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}},1602,[]); -__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])},1603,[1601]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},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}),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},1605,[355,1599]); -__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])},1606,[17,1596]); -__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}},1607,[1594,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])},1608,[1594,1607]); -__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}},1609,[1590]); -__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])},1610,[198,1590,1593,1591]); -__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})({})},1611,[]); -__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]))},1612,[198,37,1613]); -__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')},1613,[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]}},1614,[17,1589]); -__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]}})})},1615,[1616]); -__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(){}},1616,[]); -__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]})}},1617,[17,24,85,409,777,857,920,899,880,805,804,1558,1560,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()})},1618,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1619,[813,779,17,974,385,85,856,899,976,804,777,1351,971,880,1620,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1620,[17,1458,385,85,899,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1621,[]); -__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"},1622,[]); -__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"},1623,[]); -__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"},1624,[]); -__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"},1625,[]); -__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]})}},1626,[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},1627,[1628]); -__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},1628,[8,1629,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}))}}},1629,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1630,[]); -__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})}}},1631,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1278,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1279,[17,385,85,409,777,804,1190,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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1280,[17,85,1281,777,858,920,1260,1263,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1281,[17,85,1282,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1282,[1283]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1283,[17,780,1284,1313,1314,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1284,[1285]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1285,[1286,1287,1310,1312]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1286,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1287,[1288,1289,1290,1291,1292,1293,1294,1295,1296,1299,1303,1300,1304]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1288,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1289,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1290,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1291,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1296,[1297]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1300,[1301,1302]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1301,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1302,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1305,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1306,[1300]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1308,[1300,1288]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1309,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1310,[1311]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1312,[1311]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1313,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1314,[17,780,1315,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1315,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1316,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1317,[822,13,17,85,1281,777,851,858,804,1280,1263,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1318,[822,13,17,85,1258,777,858,876,851,863,804,1259,1263,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1319,[822,13,17,777,858,876,863,804,1280,1263,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1320,[822,13,17,777,858,876,804,1280,1263,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1321,[13,17,777,863,1140,1322,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1322,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1323,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1324,[843,13,17,1249,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1325,[13,17,85,1254,777,845,862,858,804,1279,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1326,[13,17,1327,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1327,[17,85,777,1099,804,1328,1329,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1328,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1329,[928,971,1328]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1330,[843,13,17,85,1256,777,845,851,863,858,804,1331,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1331,[17,354,362,219,13,777,851,804,900,1332,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1332,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1333,[843,1263,13,17,85,777,845,851,863,858,864,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]})}},1334,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1335,[822,13,17,777,858,805,1263,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1336,[13,17,777,1337,1154,1263,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1337,[812,843,17,85,777,845,851,1154,1338,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1338,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1339,[13,17,856,1340,1412,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1340,[1053,779,805,806,1341,813,1342,1094,843,1140,1343,1344,1345,1091,1122,1346,1347,1352,1353,1210,1354,856,1359,1360,1361,1115,1113,920,1362,1153,891,1104,1363,17,1072,1185,1018,1087,1364,21,378,363,385,278,85,409,19,777,1241,1245,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1365,1108,1366,1372,1374,1378,1383,1377,1384,1387,1388,1117,1095,1096,862,1393,1230,1394,1240,1232,995,1399,1404,1405,1054,1052,1119,1407,1408,1409,1071,1172,1410,1171,1162,853,1355,1411,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1343,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1344,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1345,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1346,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1347,[17,378,385,409,85,1281,777,1172,779,998,1348,1349,1351,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1348,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1349,[17,378,385,278,395,85,409,779,777,804,1350,1351,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1350,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1351,[993,856,1350,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1352,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1353,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1354,[1168,17,219,385,85,777,1167,804,876,920,1355,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1355,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1356,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1356,[831,928,899,1357,880,1358]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1357,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1358,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1359,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1361,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1362,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1363,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1364,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1365,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1366,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1367,1369,1368,998,876,1108,1370,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1367,[813,843,17,1368,85,842,804,777,1109,1369,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1368,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1369,[1368,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1370,[17,368,278,85,842,982,1371,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1371,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1372,[17,219,385,85,804,777,1172,1373,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1373,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1374,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1375,841,863,1096,1376,804,777,1377,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1375,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1376,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1377,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1378,[805,813,17,266,319,219,385,85,409,804,857,1379,777,999,916,1352,1381,880,1382,1383,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1379,[17,219,85,1380,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1380,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1381,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1383,[17,831,928,899,1382]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1384,[843,841,998,1385,1386]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1385,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1386,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1387,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1388,[1389,843,1095,998,17,85,777,1098,858,1116,1384,1096,863,1093,1117,1118,1119,804,1344,1391,1392,1115,1361,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1389,[17,362,385,85,858,920,876,996,1390,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1390,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1393,[1172,1389,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1377,858,998,845,1089,1076,1322,804,1344,1391,1392,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1394,[812,17,219,385,85,777,858,998,1395,804,1396,1398,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1395,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1396,[831,858,998,1395,1397,1398]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1397,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1398,[219,1397]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1399,[843,17,1189,1172,385,85,995,998,862,863,804,777,1400,1403,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1400,[1401,854,843,17,264,378,385,278,85,858,995,998,1402,863,804,1026,777,1403,1356,899,1344,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1401,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1402,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1403,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1405,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1406,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1407,[843,1385]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1408,[17,385,85,777,1407,804,1364,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1409,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1410,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1411,[17,1005,876,926,816,1006,916,1356,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1412,[805,813,857,17,219,385,85,409,899,804,777,1352,1413,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1413,[]); +__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]})}},1414,[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]})}},1415,[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,{})}},1416,[13,17,1417,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])},1417,[17,856,1418,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}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return H.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]),Y=_r(d[45]);_r(d[46]);var 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,Q.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,Q.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,K.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,K.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,J.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)(()=>{G.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,M.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)(z.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)(z.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'!==H.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'===H.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'===H.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.jsx)(D.AssistantRequestsButton,{go:Be,testID:"assistant-requests-top"}),(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'===H.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)(F.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(Y.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(U.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(Q.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(K.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.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)(W.OnboardingHost,{go:Be}),(0,le.jsx)(V.CoachHost,{})]})}},1418,[805,813,899,1193,1228,1210,1028,1025,891,1026,880,1032,1087,17,356,378,385,278,409,85,19,777,857,858,876,804,1419,1184,1057,884,1427,920,219,1432,1472,839,856,1474,1481,1482,1483,1190,1246,1484,1458,1485,1487,1456,1161,1230,1394,1232,1245,1489,1084,1086,1555,1556,1575,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1419,[805,1420,1095,1270,1421,812,822,1117,1118,1091,1122,1422,1114,1119,1407,1408,1057,1344,996,1120,1089,841,1386,1125,1424,1241,1425,1399,1078,1055,1090,17,85,777,1364,858,845,851,863,1322,804,1184,1098,1115,998,1361,1062,1162,1426,1232,899,1186,1404,862,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1420,[]); +__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])},1421,[806,17,85,777,899,1274,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1422,[17,385,85,1423,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1423,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1424,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1187,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1425,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1426,[17,85,864,858,848,804,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1427,[1428,17,219,24,85,856,1429,920,804,1431,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1428,[]); +__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])},1429,[17,278,85,777,857,804,1430,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(' ')},1430,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1431,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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:n=!1}){const{rid:a,r:x,now:H,role:ae,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(a),ce=(0,p.useBookings)(a),ue=(0,p.useWaitlist)(a),ge=(0,p.useEvents)(a),xe=(0,p.useRatings)(a),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,S.useRealHistory)(a,H),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,H,pe??void 0),[x,ce,de,ge,pe,H.getTime()/6e4|0]),ke=(0,M.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),Ie=de.filter(B.LIVE),ve=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=Ie.filter(e=>(0,U.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,U.bookingNeedsAction)(e,Ie)),Ae=Ie.flatMap(e=>(0,I.readinessFor)(e,x,H).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Se=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Me=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,v.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(H),He=ke?(0,L.revenueHistory)(x,H,7).filter(e=>e.date.getDay()===H.getDay()).pop():void 0,Fe=ke?{today:186e3+Ne,last:He?{date:(0,v.ymd)(He.date),pence:He.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,a,Pe,Ne),We=j.CAN.takings(ae)&&(!(0,W.isLive)()||(0,W.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,H,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(H),(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)(ae,qe,{inStaffApp:Ye,live:(0,W.isLive)()}),Ve=(0,F.homeSetupNagsHidden)(a),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,st]=(0,l.useState)(!1),ot=ie.replace(' (example)',''),lt=j.CAN.manage(ae)?(0,ne.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,ne.jsxs)(b.default,{style:{gap:12},children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(i.DayView,{rid:a,day:Ue,today:re,app:"owner"})]}):(0,ne.jsxs)(b.default,{style:{gap:12},testID:n?'owner-home':'managers-home',children:[lt,(0,ne.jsx)(i.DayBar,{app:"owner",today:re}),(0,ne.jsx)(K.WhoBar,{}),qe&&'owner'!==qe.role?(0,ne.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ne.jsx)(X.MyTasksToday,{rid:a,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ae?(0,ne.jsx)(Z.TodaysTipsCard,{rid:a,today:re}):null,'staff'!==ae?(0,ne.jsx)(Z.TipsPotCard,{rid:a,today:re}):null,j.CAN.manage(ae)?(0,ne.jsx)(b.default,{testID:"home-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.jsx)(f.Button,{testID:"home-insights-toggle",kind:tt?'secondary':'primary',label:tt?'Hide insights':'Insights',accessibilityLabel:tt?'Hide insights':'Insights: business insights, stats and suggestions. Closed until you tap.',onPress:()=>st(e=>!e),style:{minHeight:56,width:'100%'}})}):null,j.CAN.manage(ae)&&tt?(0,ne.jsxs)(b.default,{testID:"home-insights-panel",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,ne.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ne.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%'}})}),(0,ne.jsx)(le.SuperProInsights,{go:e}),(0,ne.jsxs)(b.default,{testID:"home-insights-feed",style:{gap:12,width:'100%'},children:[(0,ne.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,ne.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ne.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,ne.jsxs)(f.T,{weight:"semibold",center:!0,children:[t.icon," ",t.title]}),(0,ne.jsx)(f.Muted,{center:!0,children:t.body}),t.action?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'center'}}):null]})},t.id)),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights'),style:{alignSelf:'center'}})]})]}):null,(0,ne.jsx)(ye,{split:De}),(0,ne.jsx)(te.BlocksBanner,{rid:a,now:H,by:ie}),(0,ne.jsx)(y.KitchenSignoffs,{rid:a,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ve?(0,ne.jsx)(o.SeasonsTodo,{go:e}):null,(0,ne.jsx)(r.LastFoodBanner,{rid:a,now:H}),(0,ne.jsx)(d.NextTableFreeCard,{rid:a,now:H}),j.CAN.manage(ae)?(0,ne.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,ne.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,ne.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ne.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ae)?(0,ne.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:a,r:x,now:H,by:ie}):null]}),ze.elements,j.CAN.manage(ae)?(0,ne.jsx)(Y.PaydaysCard,{go:e}):null,(0,ne.jsx)(E.FadeIn,{children:(0,ne.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ne.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,ne.jsx)(S.ExampleBadge,{}):je.enough?(0,ne.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ne.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ne.jsx)(E.Gauge,{pct:Le?Se.pct:0,label:Le?Se.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,ne.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ne.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,je.enough?(0,ne.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,ne.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ne.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ne.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||Ie.length?(0,ne.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Live orders",value:"",accent:Ie.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${Ie.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${Ie.filter(e=>'table'===e.type).length} table`:`${Ie.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ne.jsx)(E.CountUp,{value:Ie.length})})}):null,ve.length>0?(0,ne.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ne.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,ne.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ne.jsx)(z.TakingsTodayCard,{t:Fe,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ne.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ne.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,ne.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,ne.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ne.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ne.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ne.jsx)(_.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ne.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,v.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ne.jsx)(f.T,{size:14,children:t.detail}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ge.days.length||Ge.requests)?(0,ne.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,ne.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ae)?(0,ne.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ne.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ne.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ne.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,ne.jsxs)(f.Row,{gap:4,children:[(0,ne.jsx)(G.Mark,{p:"facebook"}),(0,ne.jsx)(G.Mark,{p:"instagram"}),(0,ne.jsx)(G.Mark,{p:"tiktok"}),(0,ne.jsx)(G.Mark,{p:"youtube"})]}),(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ne.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ne.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ne.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ne.jsx)(B.SectionHead,{title:e})}),(0,ne.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ne.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ne.jsxs)(f.Card,{children:[0===Oe.length?(0,ne.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,ne.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(b.default,{style:{flex:1},children:[(0,ne.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ne.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,v.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ne.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ne.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,ne.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ne.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),Ke?(0,ne.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,ne.jsx)(E.FadeIn,{children:(0,ne.jsx)(he,{rid:a,today:re})}):null,'owner'!==ae||V.IS_CAR?null:(0,ne.jsx)(f.Button,{testID:"home-customer-support",label:"Customer support",accessibilityLabel:"Customer support, send a message or a picture to CoverCharge",onPress:()=>e('more','support'),style:{minHeight:56,width:'100%'}}),(0,ne.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:a,by:ot,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]),n=_r(_d[4]),a=e(n),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]),I=_r(_d[21]),v=_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]),S=_r(_d[29]),M=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),H=_r(_d[33]),F=_r(_d[34]),W=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),_=_r(_d[41]),U=_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]),ne=_r(_d[56]);const ae=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 a=3/Math.sqrt(n);o[e]=a*t*s[e],o[e+1]=a*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)&&n.push(e);for(;n.length&&o(e)-o(n[n.length-1])<36;)n.pop();return[...n,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&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/I*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:v(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],S=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?.(M(s)))},M=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,F=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,W=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)} ${F}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${W?` ${W.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,n)=>(0,ne.jsx)(m.default,{testID:n,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,ne.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ne.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ne.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ne.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ne.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,ne.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,ne.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ne.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:F}),(0,ne.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),W?(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:W}):null]}):(0,ne.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ne.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ne.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ne.jsxs)(a.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ne.jsx)(n.Defs,{children:(0,ne.jsxs)(n.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ne.jsx)(n.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ne.jsx)(n.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ne.jsx)(n.Line,{x1:ae,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.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,ne.jsx)(n.Circle,{cx:v(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ne.jsx)(n.Line,{x1:v(L.day),y1:10,x2:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(n.Circle,{cx:v(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,ne.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:M(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:v(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ne.jsx)(b.default,{testID:"mt-axis",style:{height:H.AXIS_BAND+6,minHeight:H.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ne.jsx)(f.T,{size:H.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:v(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ne.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ne.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>S(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ne.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:M(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ne.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ne.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,ne.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>S(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,ne.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ne.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: card + cash \u2212 card tips. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ne.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ne.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,ne.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ne.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ne.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ne.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ne.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ne.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,ne.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ne.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1432,[843,1140,1433,17,780,1185,1074,1075,1425,1344,861,1078,264,385,85,777,858,876,1211,1193,845,1160,863,1055,866,804,1184,1057,1139,1145,1146,1008,839,1150,886,899,915,1443,1444,1149,1445,1162,853,1448,1188,1209,856,1207,1031,1032,1066,1098,1399,1153,1343,1466,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."})]})}},1433,[1053,1033,805,1420,812,1434,1435,1437,1438,1439,1203,1031,1032,1008,1014,17,385,85,777,841,1440,816,862,1055,861,804,1057,858,1187,926,927,876,1441,1394,998,1442,1005,1142,892,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)},1434,[812,17,85,777,1140,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)},1435,[843,17,219,85,777,858,998,1154,1263,899,1338,1436,8]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1436,[843,1285]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1437,[17,85,777,998,1348,804,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1438,[17,85,777,998,863,1402,805,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1439,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1440,[17,1033,85,804,777,1260,1263,8]); +__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1441,[17,85,777,998,1368,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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),S=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>C(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>C(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>f(null),onSave:t=>{y.update(e.id,t),f(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",S(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>f(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:I,onCancel:()=>f(null),onSave:t=>{y.add(e,t),f(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>f('new')}),(0,k.jsxs)(r.Sheet,{visible:!!p,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:p?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{p&&y.remove(p.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{f.useOrderLists.getState().ensure(e)},[e]);const s=(0,f.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,f.orderSettingsOf)(e);(0,f.useOrderLists)(t=>t.settings[e]);const l=f.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(t=>(0,k.jsx)(r.Chip,{label:p.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),f=(0,s.privateClockVenue)(e),[p,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[S,v]=(0,n.useState)(!1),[C,I]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(f)return;v(!0),I('');const t=await(0,b.getFix)();if(v(!1),'object'!=typeof t)return void I('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),I(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:f?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),f?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),f?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:S?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:S,onPress:()=>{B()}}),C?(0,k.jsx)(r.Muted,{size:13,children:C}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:p,onChangeText:j,onBlur:()=>R(p,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(p,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),f?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"The full CookSafe log is in the food safety menu: CookSafe log."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_r(_d[5])),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},S=[1,2,3,4,5,6,0],v=['on_shift','everyone','managers','head_chef','kitchen','foh'],C=e=>e.replace(' (example)',''),I={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:C(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[v.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:C(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,f]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),p=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{f(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:S.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),p?(0,k.jsx)(r.Muted,{size:13,children:p}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!p,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>f.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1442,[812,912,17,362,385,85,777,804,1005,1006,876,1010,1011,1012,913,1068,899,1029,916,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1443,[]); +__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7])},1444,[17,385,85,777,804,1149,1443,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1445,[886,779,816,813,822,862,1039,1446,17,909,319,362,219,385,85,777,858,876,863,804,1184,1057,1221,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1446,[482,1447]); +__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}});var t={}},1447,[]); +__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.ProgressBar=L,_e.useSetupDone=F,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,T.useCtx)(6e4),n=F(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=k.SETUP_STEPS.findIndex(e=>e.id===a),s=k.SETUP_STEPS[e+1]?.id??null;return(0,R.jsx)(A,{id:a,wizard:!0,onBack:()=>l(e>0?k.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=k.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,R.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{gap:12,children:[(0,R.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsxs)(m.T,{size:20,weight:"bold",colour:C.colours.gold,children:["Set up ",t.name]}),(0,R.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,R.jsx)(L,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,R.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,R.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:C.colours.border,backgroundColor:C.colours.surface,overflow:'hidden'},children:k.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,R.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:C.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,R.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?C.colours.gold:'transparent',borderWidth:1.5,borderColor:t?C.colours.gold:C.colours.border},children:(0,R.jsx)(m.T,{weight:"bold",colour:t?C.colours.onGold:C.colours.muted,children:t?'\u2713':s+1})}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"medium",children:e.title}),(0,R.jsx)(m.Muted,{children:e.sub}),o.length?(0,R.jsxs)(m.T,{size:13,colour:C.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,R.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=A,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return V}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=F(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,R.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:C.colours.gold,children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",colour:C.colours.gold,children:"Finish setting up"}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"\u203a"})]}),(0,R.jsx)(L,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,R.jsxs)(m.Muted,{size:13,children:["Next: ",k.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]),M=_r(_d[29]),R=_r(_d[30]);const I=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=[1,2,3,4,5,6,0],B=/^([01]\d|2[0-3]):[0-5]\d$/,D=e=>{const s=(0,M.parseMoneyInput)(e);return null!=s&&s>0?Math.round(100*s):null},O=e=>k.SETUP_STEPS.findIndex(s=>s.id===e)+1;function L({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,R.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,R.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:C.colours.gold,borderRadius:5}})}),(0,R.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function F(e){const s=(0,k.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=k.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:k.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function A({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,T.useCtx)(6e4),l=F(a),r=l.prog,d=(0,i.useLiveVenue)(),u=k.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=N[e];return(0,R.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsxs)(m.T,{size:12,weight:"semibold",colour:C.colours.gold,children:["STEP ",O(e)," OF ",k.SETUP_STEPS.length]}),s&&o?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,R.jsx)(m.T,{size:13,colour:C.colours.muted,children:"All steps"})}):null]}),(0,R.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,R.jsx)(L,{done:r.done,total:r.total})]}),(0,R.jsx)(b,{rid:a,done:(t="Saved.")=>{k.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,R.jsx)(m.Banner,{kind:"success",title:p}):null,(0,R.jsx)(G,{rid:a,id:e,title:u.title,onDone:x}),s?(0,R.jsxs)(m.Row,{gap:10,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,R.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const U=({wizard:e,onPress:s,disabled:t,label:n})=>(0,R.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const _=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function W({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,T.useHourly)(),d=(0,k.useSiteSetup)(e),u=(0,k.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,f]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,S.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,k.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),f(null)},z=!!p?.id&&(E=p.id,w.ROSTER.some(e=>e.id===E));var E;const M=p?D(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=M||z&&!p.wage);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,R.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,R.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?C.colours.gold:C.colours.border,backgroundColor:s?'#1d1a14':C.colours.surface}),children:[(0,R.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,R.jsxs)(g.default,{style:{flex:1},children:[(0,R.jsx)(m.T,{weight:"semibold",children:e.name}),(0,R.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,k.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,R.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,k.accessOf)(e.level,e.role)})]},e.id))}),y?(0,R.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,R.jsxs)(m.Card,{highlight:C.colours.gold,children:[(0,R.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:C.colours.gold},children:(0,R.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,R.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,R.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,R.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,R.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,R.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Access level"}),(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:k.ACCESS_LEVELS.map(e=>(0,R.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,R.jsxs)(m.Muted,{size:13,children:["Uses the ",k.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,R.jsxs)(g.default,{style:{gap:6},children:[(0,R.jsx)(m.T,{size:14,weight:"medium",colour:C.colours.muted,children:"Pay"}),(0,R.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,R.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,R.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,R.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,R.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,R.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,S.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,R.jsx)(m.Field,{money:!0,label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=M&&M<1271?(0,R.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,R.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,R.jsxs)(m.Row,{gap:8,children:[(0,R.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,R.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),k.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:k.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=M&&s.setRate(t,M);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),k.useSetup.getState().patch(e,{staffGrade:o}),k.useSetup.getState().setLook(t,p.look),f(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,R.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,R.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(_(d.grades[0]?.id??'')),f(null)}}),(0,R.jsx)(U,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const N={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,k.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,R.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,R.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,R.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,R.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,R.jsxs)(m.Row,{gap:14,children:[(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:C.colours.border},children:(0,R.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,R.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,R.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':(0,y.builtInLogoCopy)(e)," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,R.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,R.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,R.jsx)(z.OrderAtTableCard,{rid:e,compact:!0}),u?(0,R.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,R.jsx)(U,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,T.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=$.filter(e=>{const s=n[e];return s&&(!B.test(s[0])||!B.test(s[1]))});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),I.map((e,s)=>{const t=$[s],l=n[t];return(0,R.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:C.colours.border,paddingTop:s?6:0},children:[(0,R.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,R.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,R.jsx)(m.T,{colour:C.colours.muted,children:"to"}),(0,R.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,R.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,R.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries($.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,R.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,R.jsx)(U,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,f.usePlan)(e),o=(0,f.planCounts)(n);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P.TablePlan,{startStep:"areas"}),(0,R.jsx)(U,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,R.jsx)(W,{...e,payList:!0})]})},staff:W,permissions:function({done:e,wizard:s}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E.PermissionsScreen,{}),(0,R.jsx)(U,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,k.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,R.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,R.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,R.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,R.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,R.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,R.jsx)(U,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,T.useCtx)(6e4),a=(0,k.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,v.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,R.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,R.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,R.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:C.colours.border,padding:10},children:(0,R.jsx)(m.T,{size:14,colour:C.colours.goldLight,children:i})}),(0,R.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,v.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,R.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,R.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,R.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,R.jsx)(U,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),k.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,T.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,R.jsxs)(m.Card,{children:[(0,R.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,R.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,R.jsx)(U,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},V=e=>function(){return(0,R.jsx)(A,{id:e})};function G({rid:e,id:s,title:t,onDone:n}){const o=F(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,R.jsxs)(g.default,{style:{gap:4},children:[(0,R.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),k.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,R.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,R.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1448,[888,887,813,812,1039,1449,1450,1451,1452,1454,17,385,85,857,884,777,858,876,1455,998,886,878,851,804,1057,1456,1459,1463,1464,840,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1449,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1450,[17,899]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1451,[17,831,899]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1452,[880,812,17,219,366,85,777,1453,899,804,1188,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1453,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1454,[17,385,777,899,804,1452,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.builtInLogoCopy=function(o){return'anchorage'===o?'The Anchorage logo in black and gold.':'Placeholder initials.'}},1455,[]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1456,[812,891,1140,899,780,1230,1232,17,264,362,219,385,85,409,864,777,858,1241,876,851,863,804,1184,1057,853,1055,1445,1161,1457,1458,1139,1146,1145,1008,839,1142,1149,1221,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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1457,[812,17,1228,1026,854,362,385,85,777,876,851,863,804,1184,1057,1221,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1458,[978,17,385,85,777,876,804,1057,1161,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1459,[812,17,1018,378,85,1108,1109,1366,1399,777,995,998,863,804,1057,999,1460,1461,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1460,[812,17,385,85,777,804,998,805,999,856,899,8]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1461,[17,85,777,998,1462,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1462,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1463,[805,1420,17,85,777,858,876,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.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 ')}},1464,[17,264,385,85,777,804,915,1465,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.'},1465,[928,899,876,856,915]); +__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 P}}),_e.useInsightsAccess=S,_e.SuperProInsights=_,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,D.jsx)(o.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,D.jsx)(_,{go:e})}):(0,D.jsx)(E,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.sales)return(0,D.jsx)(E,{});const r=i.sales;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Last 7 days"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=r.last7?(0,x.moneyGbp)(r.last7):'\u2014'}),r.missing7?(0,D.jsx)(l.Muted,{center:!0,children:`From ${r.days7} of ${r.days7+r.missing7} cash ups. ${r.missing7} ha${1===r.missing7?'s':'ve'} no card or cash total yet, so ${1===r.missing7?'it is':'they are'} not in the total.`}):null,(0,D.jsx)(l.Muted,{center:!0,children:null!=r.prev7?`The 7 days before: ${(0,x.moneyGbp)(r.prev7)}${null!=r.changePct?` (${r.changePct>=0?'up':'down'} ${Math.abs(r.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,D.jsx)(l.Muted,{center:!0,children:null!=r.sph7?`Spend per head ${(0,x.moneyGbp)(r.sph7)}, on the ${r.sphDays7} day${1===r.sphDays7?'':'s'} with takings and Covers`:'Spend per head shows once days have takings and Covers'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Takings by week"}),(0,D.jsx)(O,{values:r.weeks.map(e=>e.gross),w:300,h:70}),r.weeks.slice().reverse().map(e=>(0,D.jsx)(W,{a:`${(0,w.ukDate)(e.from)} \u2013 ${(0,w.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up${e.missing?`, ${e.missing} with no card or cash total`:''}`:e.missing?`Not enough data: ${e.missing} cash up${1===e.missing?'':'s'} with no card or cash total`:'No signed-off cash ups'},e.to)),(0,D.jsx)(l.Muted,{center:!0,children:"Takings are card + cash \u2212 card tips from signed-off cash ups (Gross only for a prepaid function), as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,D.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.stock)return(0,D.jsx)(E,{});const r=i.stock;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,D.jsx)(A,{example:i.example}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Low or out now"}),(0,D.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."}),r.low.length?r.low.map(e=>(0,D.jsx)(W,{testID:`low-${e.key}`,tone:e.out?k.colours.red:k.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,D.jsx)(l.Muted,{center:!0,children:r.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:`Price rises in the last ${w.RISE_DAYS} days`}),r.rises.length?r.rises.map(e=>(0,D.jsx)(W,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,$.gbp)(e.before)} \u2192 ${(0,$.gbp)(e.after)} a pack \xb7 ${(0,w.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,D.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,D.jsx)(l.Muted,{center:!0,children:r.lastCount?`Last full stock count ${(0,w.ukDate)(r.lastCount)}.`:'No full stock count yet.'})]}),(0,D.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,j.useCtx)(6e4),n=S(),i=T(s,t);if(!n.gp)return(0,D.jsx)(E,{});const r=i.gp;return(0,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,D.jsx)(A,{example:i.example}),i.example?(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,D.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:k.colours.gold,children:L(r.menu)}),null!=r.startMenu&&null!=r.menu?(0,D.jsx)(l.Muted,{center:!0,children:`${G(r.menu-r.startMenu)} points since ${(0,w.ukDate)(r.trend[0]?.week??'')}`}):null,(0,D.jsx)(O,{values:r.trend.map(e=>e.menu),w:300,h:80})]}):null!=r.menu?(0,D.jsx)(v.GpOverTime,{rid:s}):(0,D.jsx)(o.default,{testID:"insights-gp-not-enough",style:{width:'100%'},children:(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Menu GP"}),(0,D.jsx)(l.T,{weight:"semibold",center:!0,children:"Not enough data"}),(0,D.jsx)(l.Muted,{center:!0,children:`${r.fullyCosted} of ${r.costed} costed dishes have every recipe ingredient costed. Menu GP shows once ${w.MIN_FULLY_COSTED} or more are, so a part-costed dish cannot make GP look too high.`})]})}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),r.drops.length?r.drops.map(e=>(0,D.jsx)(W,{testID:`drop-${e.dishId}`,tone:k.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,w.ukDate)(e.date)}`},e.dishId)):(0,D.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,D.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:"Each dish over 3 months"}),r.dishes.length?r.dishes.map(e=>(0,D.jsx)(W,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const s=S(),n=C(),{list:i,source:r}=N(),[a,d]=(0,t.useState)('all');if(!s.clock)return(0,D.jsx)(E,{});const c='unsigned'===a?i.filter(e=>!1===e.signed):i,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,D.jsxs)(o.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,D.jsx)(A,{example:!!n}),(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,D.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${i.length})`,onPress:()=>d('all'),testID:"clock-filter-all"}),(0,D.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${i.filter(e=>!1===e.signed).length})`,onPress:()=>d('unsigned'),testID:"clock-filter-unsigned"})]}),(0,D.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:c.length?c.map(e=>(0,D.jsxs)(o.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${w.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,w.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:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?k.colours.amber:k.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,w.ukDate)(e.workDate)}`}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,children:`${w.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,D.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,D.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,D.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,D.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${w.CLOCK_DAYS} days.`})}),(0,D.jsx)(l.Muted,{center:!0,children:'server'===r?'From the server\u2019s timesheet audit.':'synced'===r?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,D.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=_r(_d[1]),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=e(i),l=_r(_d[5]),a=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),$=_r(_d[15]),x=_r(_d[16]),w=_r(_d[17]),b=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),D=_r(_d[23]);const P='SuperPro';function S(){const{role:e}=(0,j.useCtx)(6e4),s=(0,j.useSignedIn)(),t=(0,j.useInStaffApp)();return(0,w.insightsAccess)({viewRole:e,signed:s,live:(0,b.isLive)(),inStaffApp:t,perm:e=>(0,b.can)(e)})}function C(){return(0,y.useExamples)()&&!(0,b.isLive)()?I.INSIGHTS_SAMPLE:null}function N(){const e=C(),s=(0,h.useOwner)(e=>e.attendance),n=(0,h.useOwner)(e=>e.staff),[o,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(e||!(0,b.isLive)())return;let s=!0;return(0,b.readClockChanges)(w.CLOCK_DAYS).then(e=>{s&&e&&i((0,w.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,t.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const t=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:t(o),source:'server'};const i=(0,w.addDaysYmd)((new Date).toISOString().slice(0,10),-w.CLOCK_DAYS);return{list:t((0,w.clockChangesFromAttendance)(s,i)),source:'synced'}},[e,o,s,n])}function M(e){const s=C(),[n,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(s||!e||!(0,b.isLive)())return;let t=!0;return(0,b.readLoyaltyInsight)().then(e=>{t&&o(e?(0,w.loyaltyInsight)(e.raw,e.source):null)}),()=>{t=!1}},[s,e]),s?s.loyalty:e&&(0,b.isLive)()?n:null}function T(e,n){const o=C(),i=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,a.useBookings)(e),y=(0,a.useOrders)(e),$=(0,d.useReviews)(e=>e.reviews),x=(0,h.useOwner)(e=>e.attendance),b=(0,j.useHourly)(),k=(0,u.useGpCalcView)(),v=(0,a.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),D=(0,g.useShellStore)((0,f.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,t.useMemo)(()=>{if(o)return{example:!0,...o};const t=v.map(e=>({id:e.id,dish:e.dish,price:e.price,ingCount:Array.isArray(e.ingredients)?e.ingredients.length:void 0})),a=new Date,d=(0,w.salesInsight)(i,l,e,n,(0,s.coverOverridesFor)(e)),c=x.filter(e=>!e.voided&&'confirmed'===(0,h.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,j.paidMins)(e,a).paid,ratePence:b[e.staffId]??0})),u=x.filter(e=>!e.voided&&'awaiting'===(0,h.attStatus)(e)).map(e=>e.date);return{example:!1,sales:d,stock:(0,w.stockInsight)((I??[]).filter(e=>!e.group),D,(s,t)=>(0,p.fmtStockCount)(e,s,t),k.ingredients,Object.values(k.counts??{}),n),gp:(0,w.gpInsight)(k.ingredients,k.cardCosts??{},t,k.settings,Object.values(k.deliveries??{}),n),bookings:(0,w.bookingsInsight)(l,e,n),orders:(0,w.ordersInsight)(y,e,n),reviews:(0,w.reviewsInsight)($,e,n),labour:(0,w.labourInsight)(c,i,e,n,u),salesReport:(0,w.salesReportInsight)(r,e)}},[o,i,r,l,y,$,x,b,e,n,k,v,I,D])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,G=e=>`${e>0?'+':''}${e.toFixed(1)}`;function O({values:e,w:s=220,h:t=44,testID:n}){const l=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(l.length<2)return null;const a=Math.min(...l.map(e=>e.v)),d=Math.max(...l.map(e=>e.v))-a||1,c=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/d*(t-12),h=l[l.length-1];return(0,D.jsx)(o.default,{testID:n,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,D.jsxs)(r.default,{width:s,height:t,children:[(0,D.jsx)(i.Polyline,{points:l.map(e=>`${c(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:k.colours.gold,strokeWidth:2.5,fill:"none"}),(0,D.jsx)(i.Circle,{cx:c(h.i),cy:u(h.v),r:3.5,fill:k.colours.gold})]})})}function R({title:e,big:s,line:t,tone:o,onPress:i,testID:r,children:a,a11y:d,plan:c}){return(0,D.jsxs)(n.default,{testID:r,accessibilityRole:"button",accessibilityLabel:d,accessibilityHint:"Opens the detail",onPress:i,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??k.colours.gold,backgroundColor:e?k.colours.goldTint:k.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,D.jsx)(l.T,{weight:"semibold",colour:k.colours.gold,center:!0,children:e}),c?(0,D.jsx)(l.T,{size:11,weight:"semibold",colour:k.colours.goldLight,center:!0,children:c.toUpperCase()}):null,(0,D.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??k.colours.text,children:s}),(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.muted,children:t}),a,(0,D.jsx)(l.T,{size:k.font.small,center:!0,colour:k.colours.goldLight,children:"Open \u203a"})]})}function A({example:e}){return(0,D.jsxs)(o.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.T,{size:20,weight:"bold",colour:k.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,D.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,D.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function B({title:e,sub:s,children:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,D.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,D.jsx)(l.Badge,{kind:"gold",label:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]}),(0,D.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function _({go:e}){const{rid:s,today:t}=(0,j.useCtx)(6e4),n=S(),i=T(s,t),r=N(),l=M(n.loyalty);if(!n.any)return null;const a=(0,w.clockSummary)(r.list),d=(0,w.loyaltyLine)(l),c=s=>e('more',s),u=i.sales,h=i.stock,g=i.gp,p=i.bookings,f=i.orders,y=i.reviews,b=i.labour,v=i.salesReport,I=e=>w.INSIGHT_PLAN[e],C=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=n.sales||n.stock||n.gp||n.clock,E=n.bookings||n.noshows||n.orders||n.loyalty||n.reviews||n.labour||n.salesReports;return(0,D.jsxs)(o.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,D.jsx)(A,{example:i.example}),_?(0,D.jsxs)(B,{testID:"insights-group-superpro",title:P,sub:"Connected EPOS insights",children:[n.sales?(0,D.jsx)(R,{plan:I('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>c('insights-sales'),big:C(u.last7),line:null==u.last7?u.missing7?`Not enough data: ${u.missing7} cash up${1===u.missing7?'':'s'} in the last 7 days ha${1===u.missing7?'s':'ve'} no card or cash total`:'No signed-off cash ups in the last 7 days':`Last 7 days, card + cash \u2212 card tips from ${u.days7}${u.missing7?` of ${u.days7+u.missing7}`:''} cash-up day${u.days7+u.missing7===1?'':'s'}${u.missing7?` (${u.missing7} with no card or cash total)`:''}${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)}`:u.missing7?'Not enough data, the cash ups have no card or cash total':'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,D.jsx)(O,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,n.stock?(0,D.jsx)(R,{plan:I('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>c('insights-stock'),tone:h.low.length?k.colours.amber:void 0,big:h.low.length?`${h.low.length} low`:h.tracked?'None low':'\u2014',line:`${h.low.length?h.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):h.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${h.rises.length} price rise${1===h.rises.length?'':'s'} in ${w.RISE_DAYS} days`,a11y:`Stock. ${h.low.length} tracked items low or out. ${h.rises.length} price rises in ${w.RISE_DAYS} days`}):null,n.gp?(0,D.jsx)(R,{plan:I('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>c('insights-gp'),tone:g.drops.length?k.colours.amber:void 0,big:null==g.menu?'\u2014':L(g.menu),line:null==g.menu?`Not enough data: ${g.fullyCosted} of ${g.costed} costed dishes have every ingredient costed`:`Menu GP, ${g.fullyCosted} fully costed dishes${null!=g.startMenu?` \xb7 ${G(g.menu-g.startMenu)} pts in 3 months`:''} \xb7 ${g.drops.length} dish${1===g.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(g.menu)}. ${g.drops.length} dishes fell after a cost change`,children:(0,D.jsx)(O,{testID:"insight-gp-spark",values:g.trend.map(e=>e.menu)})}):null,n.clock?(0,D.jsx)(R,{plan:I('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>c('insights-clock'),tone:a.unsigned?k.colours.amber:void 0,big:String(a.total),line:`Edits in ${w.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 ${w.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,D.jsxs)(B,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[n.salesReports?(0,D.jsx)(R,{plan:I('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:C(v.gross),line:v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}${v.top.length?` \xb7 ${v.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(v.weekStart?`Week of ${(0,w.ukDate)(v.weekStart)}, ${C(v.gross)}`:'None yet')}):null,n.bookings?(0,D.jsx)(R,{plan:I('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,n.noshows?(0,D.jsx)(R,{plan:I('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?k.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}${n.sales?` (${(0,$.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,n.orders?(0,D.jsx)(R,{plan:I('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,$.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,n.reviews?(0,D.jsx)(R,{plan:I('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:y.low30?k.colours.amber:void 0,big:null!=y.avg30?`${y.avg30.toFixed(1)} \u2605`:'\u2014',line:`${y.count30} review${1===y.count30?'':'s'} in 30 days \xb7 ${y.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${y.avg30??'none'} stars from ${y.count30} reviews in 30 days`}):null,n.loyalty?(0,D.jsx)(R,{plan:I('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:d.big,line:d.line,a11y:`Loyalty. ${l?.members??'Not known'} members. ${l?.stampsMonth??'Not known'} stamps this month. ${l?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,n.labour?(0,D.jsx)(R,{plan:I('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=b.pct7&&b.pct7>35?k.colours.amber:void 0,big:null!=b.pct7?`${b.pct7}%`:'\u2014',line:null!=b.pct7?`Wages of takings on the ${b.days7} day${1===b.days7?'':'s'} with takings, last 7 days \xb7 ${C(b.labour7)} wages`:`Not enough data: no day in the last 7 has both signed-off hours and takings \xb7 ${b.paidHours7} signed-off hours`,a11y:`Wages and hours versus takings. ${b.pct7??'Not known'} percent over 7 days, ${b.paidHours7} hours`}):null]}):null]})}function E(){return(0,D.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function W({a:e,b:s,tone:t,testID:n}){return(0,D.jsxs)(o.default,{testID:n,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:k.colours.border,width:'100%'},children:[(0,D.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,D.jsx)(l.Muted,{center:!0,children:s})]})}},1466,[1467,17,385,85,780,777,858,1243,1008,905,876,895,897,864,1146,851,1468,1470,899,804,1057,1180,1471,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"coverOverridesFrom",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"coverOverridesFor",{enumerable:!0,get:function(){return c}});var o=r(_d[0]);const t={anchorage:{'2026-11-09':{covers:50,why:'BBC function, prepaid, 50 people (Gordon, 25 Nov 2026)'}}},n=(o,n)=>n?Object.fromEntries(Object.entries(t[o]??{}).map(([o,t])=>[o,t.covers])):{},c=t=>n(t,o.LIVE_VENUE_BUILD)},1467,[822]); +__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=l,_e.previousRange=function(e,n){const o=l(e,n);if('today'===n||'week'===n)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===n?1:0)-('today'===n?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===n?1:0)-('today'===n?1:0))};const[r,s]=o.from.split('-').map(Number),u=`${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=`${u.slice(0,7)}-${o.to.slice(8,10)}`;return{from:u,to:d<=c&&d>=u?d:c}},_e.changePct=function(t,e){return null==t||null==e||0===e?null:Math.round((t-e)/e*1e3)/10},_e.changeWords=function(t,e){if(null==t)return null;const n='today'===e?'yesterday':'week'===e?'last week':'last month';return 0===t?`No change vs ${n}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${n}`},_e.canSeeTakingsStats=function(t,e,n){return!('owner'!==t&&'manager'!==t||e&&!n)},_e.coversInRange=function(t,e){let s=0,l=0;for(const u of t){if(!u.date||!n(u.date,e))continue;if(!r(u.status))continue;const t=u.partySize||0;o(u)?s+=t:l+=t}const u=s+l;if(!u)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/u*100);return{total:u,walkIns:s,bookings:l,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,e,r){const l=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t)&&(s(t.status)||'noshow'===t.status));if(!l.length)return{rate:null,count:0,of:0,empty:!0};const u=l.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/l.length*1e3)/10,count:u,of:l.length,empty:!1}},_e.cancelRate=function(t,e,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&n(t.date,e)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const l=s.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(l/s.length*1e3)/10,count:l,of:s.length,empty:!1}},_e.takingsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{gross:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{gross:null,days:0,missing:u.length,missingDates:u}},_e.grossDays=u,_e.tipsInRange=function(e,o,r){let s=0,l=0;const u=[];for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.combinedTips)(c.vals);null!=e?(s+=e,l+=1):u.push(c.date)}return u.sort(),l?{tips:Math.round(100*s)/100,days:l,missing:u.length,missingDates:u}:{tips:null,days:0,missing:u.length,missingDates:u}},Object.defineProperty(_e,"completeTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"missingWords",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"takingsMissingWords",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return g}}),_e.tipsVsTakings=function(e,o,r){let s=0,l=0,u=0;for(const c of e){if(c.rid!==o||!c.confirmedAt||!n(c.date,r))continue;const e=(0,t.tillTakingsOf)(c.vals),d=(0,t.combinedTips)(c.vals);null==e||null==d||e<=0||(s+=d,l+=e,u+=1)}return u?{pct:g(Math.round(100*s)/100,Math.round(100*l)/100),days:u}:{pct:null,days:0}},_e.spendPerHeadInRange=function(t,n,o,r,s={}){const l=[...u(t,o,r).entries()].map(([t,r])=>({date:t,gross:r,covers:(0,e.coversOn)(n,o,t)+(s[t]??0)})),c=l.filter(t=>t.covers>0),d=l.length-c.length;if(!c.length)return{sph:null,covers:0,gross:null,days:0,noCovers:d};const f=Math.round(100*c.reduce((t,e)=>t+e.gross,0))/100,g=c.reduce((t,e)=>t+e.covers,0);return{sph:Math.round(f/g*100)/100,covers:g,gross:f,days:c.length,noCovers:d}},_e.labourCostInRange=h,_e.labourVsTakings=function(t,e,n,o,r){const s=u(n,o,r),l=s.size?Math.round(100*[...s.values()].reduce((t,e)=>t+e,0))/100:null,c=s.size?h(t,r,s):null;return{pct:m(c,l),labour:c,gross:l,days:s.size,awaiting:e.filter(t=>s.has(t)).length,labourAll:h(t,r)}},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return m}}),_e.repeatGuestPct=function(t,e,o){const r=new Set;for(const n of t){if(o&&n.restaurantId!==o)continue;if(!s(n.status)||n.date>=e.from)continue;const t=p(n);t&&r.add(t)}const l=new Set;let u=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!n(d.date,e))continue;const t=p(d);t&&!l.has(t)&&(l.add(t),u+=1,r.has(t)&&(c+=1))}return u?{rate:Math.round(c/u*1e3)/10,count:c,of:u,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.firstVisitDate=function(t,e){let n=null;for(const o of t)e&&o.restaurantId!==e||!s(o.status)||!o.date||(!n||o.date(null==t.status||'published'===t.status)&&n(t.createdAt.slice(0,10),e)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,e)=>t+e.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"NOT_SHOWN_YET",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return e.coversOn}});var t=_r(_d[0]),e=_r(_d[1]);const n=(t,e)=>t>=e.from&&t<=e.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function l(e,n){return'today'===n?{from:e,to:e}:'week'===n?{from:(0,t.weekStartOf)(e),to:e}:{from:`${e.slice(0,7)}-01`,to:e}}function u(e,o,r){const s=new Map;for(const l of e){if(l.rid!==o||!l.confirmedAt||!n(l.date,r))continue;const e=(0,t.tillTakingsOf)(l.vals);null!=e&&s.set(l.date,e)}return s}const c=(t,e)=>t.missing?null:e,d=(t,e,n)=>`Not enough data: ${t} cash up${1===t?' has':'s have'} no ${e} yet (${n.map(v).join(', ')})`,f=t=>`${t.length} cash up${1===t.length?' has':'s have'} no card or cash total yet (${t.map(v).join(', ')}), so ${1===t.length?'it is':'they are'} not in the total`,g=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function h(t,e,o){let r=0,s=!1;for(const l of t)!n(l.date,e)||l.ratePence<=0||l.paidMins<=0||o&&!o.has(l.date)||(r+=l.paidMins/60*l.ratePence,s=!0);return s?Math.round(r)/100:null}const m=(t,e)=>null==t||null==e||e<=0?null:Math.round(t/e*1e3)/10;function p(t){const e=(t.phone||'').replace(/\s+/g,'').toLowerCase(),n=(t.email||'').trim().toLowerCase();return e.length>=7?`p:${e}`:n.includes('@')?`e:${n}`:null}const y='Not shown yet: GP and food cost %, table occupancy and top dishes. They need till sales, which CoverCharge does not have yet.',b={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.'},k=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,v=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,w=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1468,[839,1469]); +__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,u={}){const l=(0,r.weekStartOf)(o);return Array.from({length:d},(f,h)=>{const m=(0,r.addDaysYmd)(l,7*(h-d+1)),p=i(n,t,s,(0,r.addDaysYmd)(m,6),7,u).filter(r=>r.date<=o&&null!=r.gross),v=p.length?Math.round(100*p.reduce((r,n)=>r+n.gross,0))/100:null,y=p.reduce((r,n)=>r+n.covers,0);return{weekStart:m,gross:v,covers:y,days:p.length,sph:c(v,y)}})},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,l={}){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,h)=>{const m=(0,r.addDaysYmd)(o,h-i+1),p=f.get(m)?.vals??{},v=(0,r.tillTakingsOf)(p),y=d(t,s,m)+(l[m]??0),b=u(p.food),k=u(p.drink);return{date:m,gross:v,covers:y,sph:c(v,y),food:b,drink:k,foodPh:c(b,y),drinkPh:c(k,y)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.tillTakingsOf)(n.vals))},1469,[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=d,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return c}}),_e.salesInsight=function(e,t,r,o,s={}){const a={from:d(o,-6),to:o},i={from:d(o,-13),to:d(o,-7)},l=(0,n.takingsInRange)(e,r,a),c=(0,n.takingsInRange)(e,r,i),u=(0,n.spendPerHeadInRange)(e,t,r,a,s),f=u.sph,g=[];for(let t=7;t>=0;t--){const s=d(o,-7*t),a=d(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});g.push({from:a,to:s,gross:i.gross,days:i.days,missing:i.missing})}const p=null!=l.gross&&null!=c.gross&&c.gross>0&&!l.missing&&!c.missing?Math.round((l.gross-c.gross)/c.gross*1e3)/10:null;return{last7:l.gross,prev7:c.gross,changePct:p,days7:l.days,missing7:l.missing,sphDays7:u.days,sph7:f,weeks:g,empty:g.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=d(s,-30),c=[];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&&c.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})}c.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:c,lastCount:u?.date??null,empty:!a.length&&!c.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"MIN_FULLY_COSTED",{enumerable:!0,get:function(){return g}}),_e.fullyCostedIds=p,_e.gpInsight=function(n,r,o,s,a,i){const l=p(n,r,o,s),c=o.filter(e=>(r[e.id]?.lines?.length??0)>0).length;if(l.sizel.has(e.id)),f=(0,e.menuGp)(n,r,u,s),m=(0,e.gpHistory)(a,f,'3m',i),h=m.points.find(e=>null!=e.menu)?.menu??null,b=f.dishes.map(e=>{const t=m.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)),k=(0,t.marginDrops)(a,d(i,-14)).filter(e=>u.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{fullyCosted:l.size,costed:c,menu:f.menu,startMenu:h,trend:m.points.map(e=>({week:e.week,menu:e.menu})),dishes:b,drops:k,underTarget:f.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?b(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return y(n)},_e.clockChangesFromServer=function(e){return y(e.filter(e=>h.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:k(e.action,e.old_value),after:k(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 w}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:d(r,-6),to:r},a={from:d(r,-13),to:d(r,-7)},i={from:d(r,-29),to:r},l=(0,n.coversInRange)(o,s),c=(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:c.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=d(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:d(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,o,s=[]){const a={from:d(o,-6),to:o},i=(0,n.labourVsTakings)(e,s,t,r,a),l=e.filter(e=>e.date>=a.from&&e.date<=a.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:i.labour,takings7:i.gross,pct7:i.pct,days7:i.days,paidHours7:Math.round(l/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=v(e.members),r=v(e.stampsMonth),o=v(e.rewardsUsedMonth??e.rewardsMonth),s=v(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 d(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 c=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14,g=5;function p(e,n,r,o){const s=new Set;for(const a of r){const r=n[a.id];if(!r||!r.lines?.length)continue;if(null==a.ingCount||r.lines.length0||i.priceIsSuggested||s.add(a.id)}return s}const m={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'},h=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),b=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 k(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:b(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const y=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const w=30;const v=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1470,[908,906,1468]); +__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},1471,[]); +__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.useAssistantRequestInbox=x,_e.AssistantRequestsButton=function({go:e,testID:t}){const{visible:s,count:l}=x();return s?(0,b.jsx)(n.default,{style:{width:'100%',maxWidth:900,alignSelf:'center',paddingHorizontal:14,paddingTop:4,paddingBottom:8},children:(0,b.jsx)(o.Button,{testID:t??'assistant-requests-btn',label:l?`Assistant requests \xb7 ${l}`:'Assistant requests',accessibilityLabel:(0,p.assistantRequestsButtonLabel)(l),accessibilityHint:"Opens the list of changes your assistant has asked you to confirm or decline",kind:l?'primary':'secondary',onPress:()=>e('more','assistant-requests'),style:{minHeight:56}})}):null},_e.AssistantRequestsPage=function(){const{rows:e,load:t,visible:s}=x();if(!s)return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner can confirm or decline assistant changes, and only when an assistant is paired."})]});return(0,b.jsxs)(n.default,{testID:"assistant-requests-page",style:{gap:12,paddingBottom:24},children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistant requests"}),(0,b.jsx)(o.Muted,{center:!0,children:"Each change waits for an owner to approve or decline it. Important changes ask a second time."}),(0,b.jsx)(w,{rows:e,onChanged:()=>{t()}})]})},_e.AssistantPendingCard=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(null),c=async()=>{try{r(await(0,l.assistantProposalsList)())}catch{r([])}};return(0,t.useEffect)(()=>{if(!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR)return;c();const t=setInterval(()=>{c()},2e4);return()=>clearInterval(t)},[e,s,n]),!e||'owner'!==s||n||'owner'!==u.APP_VARIANT||u.IS_CAR?null:(0,b.jsx)(w,{rows:o,onChanged:()=>{c()},compact:!0})},_e.AssistantsPage=function(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),[s,r]=(0,t.useState)(''),[u,h]=(0,t.useState)(null),[p,x]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[A,I]=(0,t.useState)(null),[k,D]=(0,t.useState)(null),[C,S]=(0,t.useState)(null),[T,P]=(0,t.useState)(null),L=async()=>{try{P(await(0,l.assistantAccess)())}catch{P({plan:null,allowed:!1,reason:'Could not check this plan.'})}try{v(await(0,l.assistantList)())}catch{v([])}try{I(await(0,l.assistantProposalsList)())}catch{I([])}try{D(await(0,l.assistantAuditList)())}catch{D([])}};(0,t.useEffect)(()=>{e&&L()},[e]);const R=s.replace(/\D/g,''),$=!!T?.allowed,M=async()=>{x(!0),h(null);const e=await(0,l.assistantApprove)(R);x(!1),e.ok?(r(''),h({ok:!0,text:'Done. The assistant is paired. It can look things up and propose changes, which wait for an owner to confirm on their phone.'}),L()):h({ok:!1,text:e.message})},q=async(e,t)=>{x(!0),h(null);const s=await(0,l.assistantSetEnabled)(e.id,t);x(!1),s.ok?(h({ok:!0,text:t?`${e.label} is switched on.`:`${e.label} is switched off. It stays paired, and you can switch it on again.`}),L()):h({ok:!1,text:s.message})};return(0,b.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,b.jsx)(w,{rows:A,onChanged:()=>{L()}}):null,(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair your assistant"}),(0,b.jsx)(o.T,{center:!0,children:f}),(0,b.jsx)(o.T,{center:!0,children:"Ask your assistant, such as Grok Bot, to start CoverCharge sign-in. It will show 6 numbers. Only an owner of this venue can approve it. In the connected assistant it can answer questions about your venue and give advice from the data it is allowed to look up. It can propose a change; nothing is changed until an owner confirms it on their 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 a second time, with a plain warning of what is affected."}),!$&&T?(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-plan-blocked",children:T.reason||'Connecting an AI assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.'}):null,(0,b.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:s,onChangeText:e=>r(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,b.jsx)(o.Button,{testID:"assistant-approve",label:p?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs your AI assistant with this venue",disabled:!e||!$||p||6!==R.length,onPress:()=>{M()},style:{minHeight:56}}),e?null:(0,b.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,b.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!u,accessibilityLabel:u?.text,children:u?(0,b.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:u.ok?c.colours.goldLight:c.colours.amber,children:u.text}):null}),(0,b.jsx)(o.Muted,{center:!0,children:"Never send a personal app link to the bot. That link stays on your phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, it cannot read other venues, and it cannot change its own access or pairing."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(t=>(0,b.jsxs)(n.default,{testID:`assistant-row-${t.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:`${t.label} \xb7 ${!1===t.enabled?'switched off':'paired'}`}),(0,b.jsx)(o.Muted,{center:!0,children:`Since ${y(t.approvedAt)}. Last seen ${y(t.lastSeenAt)}.${t.ownerName?` Tied to ${t.ownerName}.`:''}`}),(0,b.jsx)(o.Toggle,{testID:`assistant-enabled-${t.id}`,label:"Assistant on",value:!1!==t.enabled,disabled:p||!e,onChange:e=>{q(t,e)},a11y:!1===t.enabled?`Switch on ${t.label}`:`Switch off ${t.label}`}),(0,b.jsx)(o.Button,{testID:`assistant-revoke-${t.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${t.label}`,onPress:()=>S(t),style:{minHeight:56}})]},t.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Activity log"}),(0,b.jsx)(o.Muted,{center:!0,children:"Everything this venue\u2019s assistants do is logged here, including look-ups. The assistant cannot change or skip this log."}),null===k?(0,b.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):k.length?k.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-audit-${e.id}`,style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",children:e.detail||e.action}),(0,b.jsx)(o.Muted,{center:!0,children:`${y(e.at)}${e.actorName?` \xb7 ${e.actorName}`:''}`})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,testID:"assistant-audit-empty",children:"No activity yet."})]}),C?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>S(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,b.jsx)(o.T,{center:!0,children:`${C.label} stops working straight away. Any changes still waiting are cancelled. Your phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,b.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=C;S(null);const t=await(0,l.assistantRevoke)(e.id);h(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),L()},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>S(null),style:{minHeight:56}})]}):null]})};var t=_r(d[0]),s=e(_r(d[1])),n=e(_r(d[2])),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]);const y=e=>e?`${(0,r.niceDate)(new Date(e))} at ${(0,r.hm)(new Date(e))}`:'not yet',f='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.';function w({rows:e,onChanged:r,compact:u}){const h=(e??[]).filter(e=>'pending'===e.status),[f,w]=(0,t.useState)(null),[x,j]=(0,t.useState)(null),[v,A]=(0,t.useState)(null),I=async(e,t,n=!1)=>{w(e.id),j(null);const o=await(0,l.assistantProposalDecide)(e.id,t,n);if(w(null),o.ok){A(null);const e='decline'===t?'Declined. Nothing was changed.':'Done. The change has been made.';j(e),s.default.announceForAccessibility(e),r?.()}else j(o.message),s.default.announceForAccessibility(o.message)};return!h.length&&u?null:(0,b.jsx)(n.default,{testID:u?'assistant-pending-home':'assistant-pending-list',children:(0,b.jsxs)(o.Card,{children:[(0,b.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Waiting for an owner to confirm"}),e?h.length?h.map(e=>(0,b.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:8,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,alignItems:'center'},children:[(0,b.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,b.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${y(e.expiresAt)}.`:'']}):e.expiresAt?(0,b.jsx)(o.Muted,{center:!0,children:`Runs out at ${y(e.expiresAt)}.`}):null,e.canDecide?(0,b.jsxs)(n.default,{style:{gap:8,width:'100%',maxWidth:520,alignSelf:'center'},children:[(0,b.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:f===e.id?'Working\u2026':'Approve',accessibilityLabel:(0,p.assistantRequestActionLabel)('Approve',e.summary),accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!f,onPress:()=>{e.needsDoubleConfirm?A(e):I(e,'approve')},style:{minHeight:56}}),(0,b.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",accessibilityLabel:(0,p.assistantRequestActionLabel)('Decline',e.summary),disabled:!!f,onPress:()=>{I(e,'decline')},style:{minHeight:56}})]}):(0,b.jsx)(o.Muted,{center:!0,children:"Only an owner of this venue can confirm or decline this on their phone."})]},e.id)):(0,b.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,b.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),(0,b.jsx)(n.default,{accessible:!0,accessibilityLiveRegion:"polite",accessibilityRole:"text",testID:"assistant-requests-status",style:{minHeight:x?void 0:0},children:x?(0,b.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:x}):null}),v?(0,b.jsxs)(o.Sheet,{visible:!0,onClose:()=>A(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,b.jsx)(o.T,{center:!0,accessibilityRole:"header",children:v.summary}),(0,b.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."}),v.warning?(0,b.jsx)(o.Muted,{center:!0,children:v.warning}):null,(0,b.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:f===v.id?'Working\u2026':'Yes, make this change',disabled:!!f,accessibilityLabel:`Yes, make this change: ${v.summary}`,onPress:()=>{I(v,'approve',!0)},style:{minHeight:56}}),(0,b.jsx)(o.Button,{kind:"secondary",label:"Go back",accessibilityLabel:`Go back without changing: ${v.summary}`,onPress:()=>A(null),style:{minHeight:56}})]}):null]})})}function x(){const e=(0,l.useSync)(e=>'staff'===e.kind&&!!e.venueId),{role:s}=(0,h.useCtx)(3e4),n=(0,h.useInStaffApp)(),[o,r]=(0,t.useState)(0),[c,b]=(0,t.useState)(null),y=async()=>{try{const[e,t]=await Promise.all([(0,l.assistantList)(),(0,l.assistantProposalsList)()]);r((e??[]).length),b(t??[])}catch{r(0),b([])}};(0,t.useEffect)(()=>{if('owner'!==u.APP_VARIANT||u.IS_CAR||n||'owner'!==s||!e)return;y();const t=setInterval(()=>{y()},2e4);return()=>clearInterval(t)},[e,s,n]);const f=(c??[]).filter(e=>'pending'===e.status).length;return{visible:(0,p.canSeeAssistantRequests)({appVariant:u.APP_VARIANT,isCar:u.IS_CAR,inStaffApp:n,role:s,live:e,pairedCount:o}),count:f,rows:c,load:y,paired:o}}},1472,[17,264,85,777,899,863,804,856,1057,1473,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.assistantRequestActionLabel=function(t,s){const n=String(s||'this change').replace(/\s+/g,' ').trim().replace(/\.+$/,'');return`${t}: ${n||'this change'}`},e.assistantRequestsButtonLabel=function(t){const s=Math.max(0,Math.floor(Number(t)||0));return 1===s?'Assistant requests, 1 waiting':`Assistant requests, ${s} waiting`},e.canSeeAssistantRequests=function(t){return'owner'===t.appVariant&&!t.isCar&&!t.inStaffApp&&'owner'===t.role&&!!t.live&&(t.pairedCount??0)>0}},1473,[]); +__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"})]})}},1474,[817,1190,17,264,266,347,378,219,278,85,19,777,857,860,876,998,1036,1037,805,842,1034,1475,804,856,1057,1476,1479,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}}},1475,[1034]); +__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=C,_e.importQuestionnaireAccounts=B,_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. 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)(i.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:l}=(0,x.useCtx)(6e4),j='owner'===n,I=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],M=(0,p.useQuestionnaire)(e),{mark:P}=(0,p.useProvenance)(e),[A,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(M?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!I.some(n=>n.provider===e.provider)),[M,I]),W=(M?.accounts??[]).some((e,n)=>P('accounts',n,'provider'));return(0,y.jsxs)(i.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)(i.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:P('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:l})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>M&&B(e,M,l)}):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:`${I.length}`})]}),I.length?I.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(M?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(i.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)(i.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:P('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:T[e.status].kind,label:T[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)(C,{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=I.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:A,owner:j,by:l,onClose:()=>z(null)}),$?(0,y.jsx)(k,{rid:e,c:$,by:l,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),l=e(r(d[4])),i=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)(i.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 C({rid:e,compact:n}){const{role:o,me:l}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,C]=(0,t.useState)({}),[B,I]=(0,t.useState)(null),T=u.useAccounts.getState();return(0,y.jsxs)(i.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)(i.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)(i.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)(i.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)(i.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>C({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(i.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:()=>T.update(e,o.id,{accountNo:u},l,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>I(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>T.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:l})})}),(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)}),B?(0,y.jsx)(k,{rid:e,c:B,by:l,onClose:()=>I(null)}):null]})}function k({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)(i.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:["CoverCharge will stop listing ",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 B(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const l of n.accounts??[])o.some(e=>e.provider===l.provider)||s.add(e,{provider:l.provider,handle:l.handle,status:'listed',from:'questionnaire',addedBy:t})}function I({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,C]=(0,t.useState)(p?.handle??''),[k,B]=(0,t.useState)(p?.customName??''),[I,T]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const M=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${M?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(l.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(i.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:M?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),M?(0,y.jsx)(a.Field,{label:"Service name",value:k,onChangeText:B,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:()=>T(!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."]})]}),I?(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, 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:C,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:M?'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:M&&k.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:M?k.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:M&&!k.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)(i.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)(i.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)(i.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 T={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)(I,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1476,[812,17,362,385,278,85,777,1477,1478,804,1474,1057,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)},1477,[]); +__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)}))},1478,[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})]})}},1479,[17,385,85,777,860,1478,998,842,1480,1475,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'},1480,[]); +__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}},1481,[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])},1482,[1185,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1182,1445,1162,860,1186,853,1184,884,1361,998,843,1115,1199,1206,1071,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']}},1483,[17,1055,85,409,777,858,1141,1140,861,863,804,876,1184,1057,1149,1145,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}))},1484,[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]})]})}},1485,[805,1420,843,1394,17,85,777,858,860,866,845,851,1160,1105,863,804,1184,1057,1161,1162,853,1426,848,900,1486,8]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const a=!!e.settings.takeawayPaused;return(0,u.jsx)(l.Card,{highlight:a?r.colours.red:void 0,children:(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(l.T,{weight:"semibold",children:a?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,u.jsx)(l.Muted,{children:a?'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,u.jsx)(l.Toggle,{testID:"takeaway-pause",label:a?'Resume':'Pause',value:!a,onChange:a=>t.useStore.getState().updateSettings(e.id,{takeawayPaused:!a})})]})})},_e.TakeawayMenuList=function({me:e}){const[s,t]=(0,a.useState)(!1),c=(0,o.useStaffTakeaway)(e=>e.rows),h=(0,o.useStaffTakeaway)(e=>e.canSet),f=(0,o.useStaffTakeaway)(e=>e.busy),w=(0,o.useStaffTakeaway)(e=>e.error),y=(0,o.useStaffTakeaway)(e=>e.loadedAt);(0,a.useEffect)(()=>{s&&(0,o.loadStaffTakeaway)(!0)},[s]);const k=c?Object.values(c).sort((e,a)=>e.section.localeCompare(a.section)||e.dish.localeCompare(a.dish)):null,j=k?.filter(e=>e.onMenu).length??0,x=y>0&&null===c;return(0,u.jsxs)(l.Card,{children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",k?` \xb7 ${j} of ${k.length} available`:'']}),(0,u.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Hide':'Choose dishes',onPress:()=>t(!s),testID:"takeaway-menu"})]}),s?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(l.Muted,{children:"The whole menu shows on the takeaway page. Switch off what can\u2019t be done for takeaway today: guests see it as \u201cNot available for takeaway today\u201d. A dish also needs Head Chef allergen sign-off and a price."}),!h&&k?(0,u.jsx)(l.Muted,{children:"Only the Head Chef, a manager or an owner can change this."}):null,x?(0,u.jsx)(l.Banner,{kind:"warn",children:"Connect to the venue to see the takeaway menu."}):null,w?(0,u.jsx)(l.Banner,{kind:"warn",children:w}):null,k||x||w?null:(0,u.jsx)(l.Muted,{children:"Loading\u2026"}),(k??[]).map(a=>(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsxs)(l.T,{size:14,children:[a.dish,a.pricePence?` \xb7 ${(0,d.gbp)(a.pricePence)}`:'']}),(0,u.jsxs)(l.Row,{gap:4,children:['Specials board'===a.section?(0,u.jsx)(l.Badge,{kind:"gold",label:"Special"}):null,a.soldOut?(0,u.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,a.signedOff?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),a.pricePence?null:(0,u.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),h?(0,u.jsx)(l.Toggle,{label:"Available for takeaway",a11y:`Available for takeaway, ${a.dish}`,value:a.onMenu,disabled:f===a.itemId,onChange:s=>{(0,o.setTakeawayAvailable)(a.itemId,s,e).catch(()=>{})}}):(0,u.jsx)(l.T,{size:14,colour:a.onMenu?r.colours.gold:r.colours.muted,children:a.onMenu?'Available':'Not today'})]},a.itemId))]}):null]})};var e,a=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),t=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),u=_r(_d[7])},1486,[17,85,777,858,851,1159,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 Ce}});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]),w=_r(d[16]),v=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),I=_r(d[22]),M=_r(d[23]),G=_r(d[24]),O=_r(d[25]),E=_r(d[26]),B=_r(d[27]),x=_r(d[28]),D=_r(d[29]),N=_r(d[30]),L=(e=N)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),q=_r(d[33]),Q=_r(d[34]),F=_r(d[35]),U=_r(d[36]),V=_r(d[37]),W=_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]),ye=_r(d[64]);const Ce=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},me=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:me,C:v.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=>me(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:me,C:O.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:me,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=>me(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:me,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:me,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:me,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:me,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:me,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:me,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:me,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:E.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:me,C:G.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:me,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:B.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:B.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:me,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:me,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:me,C:w.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:B.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:B.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:B.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:me,C:B.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:me,C:B.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:me,C:B.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:me,C:B.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:me,C:B.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:B.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:me,C:B.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:B.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:()=>Ce(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:me,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:me,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:me,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:me,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:me,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:me,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const Se=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(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:Se,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:Se,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:me,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:me,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:me,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:me,C:F.DisplaySettingsPage}]);const ke=e=>'owner'===e||'manager'===e;U.ASSISTANT_AVAILABLE&&V.ASSISTANT_UI&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:ke,C:U.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:ke,C:U.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:Y.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair your own AI assistant with a 6-digit code, switch it off, or unpair it',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantsPage}]),(0,y.register)([{id:'assistant-requests',title:'Assistant requests',sub:'Confirm or decline changes your assistant has proposed',group:'Start here',can:e=>'owner'===e&&!r.IS_CAR,C:j.AssistantRequestsPage}]);const we=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:I.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:I.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:I.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:I.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:I.InsightsClockPage}]);const Pe=()=>{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)},Re=e=>we(e)&&Pe();(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:we,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:Re,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:Re,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:Re,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:we,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:we,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:we,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:me,C:z.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:me,C:z.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:me,C:z.Outbox}]);const Ae=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:Ae,C:J.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:J.optinsAllowed,C:J.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Ae,C:$.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Ae,C:K.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:Ae,C:X.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:Ae,C:Z.OrderSheetSettings},...ee.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Ae,C:(0,K.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Ae,C:te.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Ae,C:se.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:me,C:se.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Ae,C:se.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:Ae,C:ae.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:me,C:ie.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:me,C:ie.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:me,C:ie.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:me,C:re.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos and Show me where',group:'Start here',can:me,C:oe.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:me,C:ue.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:me,C:le.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:le.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ce.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,de.useCtx)(6e4),o=(0,de.useSignedIn)();return L.default.createElement(ge.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:we,C:function(){const{rid:e,today:t}=(0,de.useCtx)(6e4);return L.default.createElement(ge.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(pe.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:me,C:ne.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,de.useCtx)(6e4),s=(0,de.useSignedIn)();return L.default.createElement(he.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:me,C:be.NightlyReportPage}]),(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:ye.UseOnComputerPage}]),(0,y.register)([{id:'support',title:'Customer support',sub:'Send a message or a picture to CoverCharge',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:fe.SupportChatPage}])},1487,[822,1050,856,1488,876,920,909,816,866,1490,1497,1499,1458,1500,1501,1503,1504,1161,1483,1505,1506,1507,1466,1202,1193,1485,1508,1456,1509,1510,17,1199,1182,1457,1445,1459,1515,1214,1521,1522,1472,1523,1448,1433,1524,1463,1525,886,1526,1527,1529,1188,1474,1530,1394,1476,1542,1081,1057,1203,1153,1546,1549,1552,1554]); +__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)}},1488,[17,378,219,385,85,19,777,1026,1340,876,804,1489,1190,1484,1057,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}))},1489,[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}},1490,[812,1454,17,851,85,777,876,804,1057,884,885,1491,899,916,1031,1452,1492,1493,1495,996,1496,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},1491,[]); +__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])},1492,[812,17,85,777,804,876,1356,1355,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])},1493,[17,85,777,1494,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},1494,[831,928,899,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]},1495,[17,85,777,804,914,1022,899,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])},1496,[928,899]); +__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 h}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LINE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_LITE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_AI_ASSISTANT_TERM",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return C}}),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 U}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return $}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),h=(0,u.trialStatus)((0,l.defaultSimStart)(),e),[y,f]=(0,t.useState)(!1);return i.CAN.billing(n)?y?(0,p.jsx)(q,{onBack:()=>f(!1)}):(0,p.jsxs)(o.default,{style:{gap:10},children:[(0,p.jsx)(s.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,p.jsxs)(s.Card,{highlight:d.colours.gold,children:[(0,p.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,p.jsxs)(s.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[S,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-early-term",children:D})]}),(0,p.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:Y.map(([e,t])=>(0,p.jsxs)(o.default,{testID:e===b?'plan-early-guest-app':e===x?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,p.jsxs)(s.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,p.jsx)(s.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,p.jsx)(s.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,N,M,z,'Usual price',''],['plan-usual-pro',E,R,U,G,'Usual price',''],['plan-superpro',k,C,F,V,'1-year contract','No hardware included.']].map(([e,t,n,l,i,u,c])=>(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(s.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,p.jsx)(s.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,p.jsxs)(s.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,p.jsx)(s.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,p.jsx)(s.Muted,{center:!0,children:S}),(0,p.jsx)(s.Muted,{center:!0,children:l}),'plan-superpro'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-superpro-epos-line",children:B}):null,i.map(e=>(0,p.jsxs)(s.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),'plan-usual-lite'===e?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-lite-ai",children:I}):null,c?(0,p.jsx)(s.Muted,{center:!0,children:c}):null]})},e)),(0,p.jsx)(s.Muted,{center:!0,testID:"plan-terms",children:$}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>f(!0),style:{alignSelf:'center'}}),(0,p.jsx)(s.Card,{children:(0,p.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,p.jsxs)(s.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,p.jsx)(s.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,p.jsx)(s.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,p.jsx)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{children:"Free trial"}),(0,p.jsxs)(s.T,{weight:"bold",colour:d.colours.gold,children:[h.daysLeft," day",1===h.daysLeft?'':'s'," left"]})]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-h.daysLeft/h.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,p.jsxs)(s.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,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'center'},gap:8,children:[(0,p.jsx)(s.T,{weight:"semibold",children:"Free customer support"}),(0,p.jsx)(s.Badge,{kind:"gold",label:"Included"})]}),(0,p.jsxs)(s.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,p.jsx)(s.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},s=r(_d[2]),l=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]);const h=!0,y='Early adopter offer, usual prices, free trial, set-up guide',f='. 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',b='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',j='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',x='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.',_='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',v='AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',I='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer.',O='AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',S='+ VAT if applicable, per venue',L='Customer & Takeaway App',E='Full Restaurant Pro App',k='SuperPro',N='\xa349',R='\xa399',C='\xa3149',M='The lite version: core features for smaller venues.',U='Every feature, every app.',F='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',B='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.',D='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.',Y=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',D],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[b,A],['Free customer support','For the length of your subscription.'],[x,T],[v,v],[j,w]],z=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',b,P,j],G=['Owner dashboard and admin','Supplier links',x,v,b,P,j],V=['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',_,v,b,P,j],$='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. AI assistant connection comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. It can answer questions about your venue, give advice, draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged.',K=[['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 q({onBack:e}){const[n,l]=(0,t.useState)([]);return(0,p.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,p.jsx)(s.H2,{children:"Set-up guide"}),(0,p.jsxs)(s.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",K.length," done."]}),(0,p.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,p.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/K.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),K.map(([e,t],i)=>{const u=n.includes(i);return(0,p.jsx)(s.Card,{children:(0,p.jsxs)(s.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.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,p.jsx)(s.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,p.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(s.T,{weight:"semibold",children:e}),(0,p.jsx)(s.Muted,{children:t}),(0,p.jsx)(s.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>l(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,p.jsx)(s.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1497,[17,85,777,835,876,1498,804,1057,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'}},1498,[]); +__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]})]})]})}},1499,[805,1033,891,1420,813,812,822,1263,1440,17,385,393,85,864,777,858,876,845,851,863,804,1184,1057,1161,1445,1221,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])},1500,[843,17,85,1162,777,858,845,853,863,804,1184,1057,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])},1501,[1039,17,85,1502,814,857,777,876,804,1057,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}})},1502,[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])},1503,[17,1155,847,1057,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])},1504,[17,1032,1057,899,915,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])},1505,[17,1400,1057,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=b,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,u.useCtx)(6e4),n=(0,o.useBookings)(e),i=(0,d.useCashUp)(e=>e.cashUps),[j,w]=(0,s.useState)('day'),f=(0,h.hasAnyTakings)(i,e),k=(0,l.coverOverridesFor)(e),v=(0,h.dayRows)(i,n,e,t,14,k),$=(0,h.weekRows)(i,n,e,t,8,k),T=(0,h.averageSph)(v),S=(e,s,t,l,n)=>(0,p.jsxs)(a.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:c.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===l?'no takings entered':`spend per head ${l}`}, ${t}${n?`, ${n}`:''}`,children:[(0,p.jsx)(r.T,{center:!0,children:s}),(0,p.jsx)(r.T,{center:!0,colour:c.colours.muted,children:t}),(0,p.jsx)(r.T,{center:!0,weight:"semibold",colour:'No takings entered'===l?c.colours.muted:c.colours.goldLight,size:'No takings entered'===l?13:16,children:l}),n?(0,p.jsx)(r.Muted,{center:!0,children:n}):null]},e);return(0,p.jsxs)(a.default,{style:{gap:12},testID:"sph-screen",children:[(0,p.jsx)(r.Muted,{children:"Tip: spend per head is takings \xf7 Covers. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,p.jsxs)(r.Card,{highlight:c.colours.gold,children:[(0,p.jsx)(r.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==T?(0,p.jsx)(r.T,{size:22,weight:"semibold",colour:c.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,p.jsxs)(r.T,{size:34,weight:"bold",colour:c.colours.goldLight,testID:"sph-avg",children:[x(T)," ",(0,p.jsx)(r.T,{size:16,colour:c.colours.muted,children:"per head"})]}),(0,p.jsx)(r.Muted,{children:f?'Only days with a cash up are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has card and cash totals.'})]}),(0,p.jsxs)(r.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(r.Chip,{testID:"sph-day",label:"By day",selected:'day'===j,onPress:()=>w('day')}),(0,p.jsx)(r.Chip,{testID:"sph-week",label:"By week",selected:'week'===j,onPress:()=>w('week')})]}),'day'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by day"}),(0,p.jsx)(b,{testID:"sph-trend-day",label:"Spend per head trend by day",points:v.map(e=>({label:y(e.date),value:e.sph}))}),[...v].reverse().map(e=>S(e.date,y(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':x(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${x(e.foodPh)}, drink ${x(e.drinkPh)} per head`:void 0))]}):null,'week'===j?(0,p.jsxs)(r.Card,{children:[(0,p.jsx)(r.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,p.jsx)(b,{testID:"sph-trend-week",label:"Spend per head trend by week",points:$.map(e=>({label:`w/c ${y(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...$].reverse().map(e=>S(e.weekStart,`w/c ${y(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':x(e.sph)))]}):null,(0,p.jsx)(r.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=_r(_d[1]),a=e(_r(_d[2])),n=_r(_d[3]),i=e(n),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]);const x=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function b({points:e,testID:l,label:o}){const[d,h]=(0,s.useState)(320),[u,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,l]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,u)),w=Math.max(0,j-b),f=e.slice(w,j),k=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)),T=e=>38+e*(k-76)/Math.max(1,f.length-1),S=e=>140-e/$*106,L=[];let D=[];f.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} ${x(e.value)}`).join(', ');return(0,p.jsxs)(a.default,{testID:l,onLayout:e=>h(e.nativeEvent.layout.width),style:{gap:8},children:[(0,p.jsxs)(a.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,p.jsx)(i.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,p.jsx)(n.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:c.colours.muted,children:x($*e/4)},e))}),(0,p.jsxs)(i.default,{width:k,height:170,children:[[0,1,2,3,4].map(e=>(0,p.jsx)(n.Line,{x1:0,x2:k,y1:S($*e/4),y2:S($*e/4),stroke:c.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,p.jsx)(n.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:c.colours.gold,strokeWidth:2.5},s)),f.map((e,s)=>(0,p.jsx)(t.default.Fragment,{children:null==e.value?(0,p.jsx)(n.Circle,{cx:T(s),cy:140,r:2,fill:"#444"}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.Circle,{cx:T(s),cy:S(e.value),r:4,fill:c.colours.goldLight}),(0,p.jsx)(n.Text,{x:T(s),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:c.colours.goldLight,children:x(e.value)})]})},w+s))]})]}),(0,p.jsx)(a.default,{style:{flexDirection:'row',gap:12},children:f.map((e,s)=>(0,p.jsxs)(a.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':x(e.value)}`,children:[(0,p.jsx)(r.T,{center:!0,size:12,colour:c.colours.muted,children:e.label}),(0,p.jsx)(r.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?c.colours.muted:c.colours.goldLight,children:null==e.value?'No takings entered':x(e.value)})]},w+s))}),(0,p.jsxs)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(r.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,p.jsx)(r.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))})]})]})}},1506,[17,1467,85,780,777,858,1008,1469,804,1057,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])},1507,[17,85,1349,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])},1508,[17,776,1057,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:a,role:I,today:x,signedIn:j}=(0,b.useCtx)(),[D,P]=(0,t.useState)('today'),R=(0,r.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),W=(0,c.useOwner)(e=>(0,c.liveAttendance)(e.attendance)),C=(0,b.useHourly)(),S=(0,$.useReviews)(e=>e.reviews),N=(0,u.canSeeTakingsStats)(I,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,v.ensureReviewSync)(e,'manage')},[e]);const M=(0,u.rangeFor)(x,D),L=(0,u.previousRange)(x,D),G=(0,t.useMemo)(()=>R.filter(s=>s.restaurantId===e),[R,e]),_=(0,u.coversInRange)(G,M),O=(0,u.coversInRange)(G,L),B=(0,u.noShowRate)(G,M,e),F=(0,u.noShowRate)(G,L,e),A=(0,u.cancelRate)(G,M,e),H=(0,u.cancelRate)(G,L,e),V='today'===D?(0,h.laterTodayCovers)(G,x):0,z=(0,u.takingsInRange)(T,e,M),U=(0,u.takingsInRange)(T,e,L),E=(0,s.coverOverridesFor)(e),Y=(0,u.spendPerHeadInRange)(T,G,e,M,E),q=(0,u.spendPerHeadInRange)(T,G,e,L,E),J=(0,u.tipsInRange)(T,e,M),K=(0,u.tipsInRange)(T,e,L),Q=(0,t.useMemo)(()=>W.filter(e=>'confirmed'===(0,c.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,b.paidMins)(e,a).paid,ratePence:C[e.staffId]??0})),[W,C,a]),X=(0,t.useMemo)(()=>W.filter(e=>'awaiting'===(0,c.attStatus)(e)).map(e=>e.date),[W]),Z=(0,u.labourVsTakings)(Q,X,T,e,M),ee=(0,u.labourVsTakings)(Q,X,T,e,L),se=(0,u.tipsVsTakings)(T,e,M),te=(0,u.firstVisitDate)(G,e),ae=(0,u.repeatGuestPct)(G,M,e),ne=(0,u.repeatGuestPct)(G,L,e),ie=(0,u.reviewAverage)(S.filter(s=>s.restaurantId===e),M),oe='today'===D?'today':'week'===D?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(o.T,{weight:"semibold",size:y.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(o.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)(o.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(o.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:D===e.id,onPress:()=>P(e.id)},e.id))}),(0,f.jsx)(w,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${oe}`,value:(0,u.pctLabel)(_.walkInPct),detail:_.empty?void 0:`${_.walkIns} walk-in covers \xb7 ${_.bookings} booked covers \xb7 ${_.total} total`,change:(0,u.changeWords)((0,u.changePct)(_.walkInPct,O.walkInPct),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${oe}`,value:(0,u.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(B.rate,F.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${oe}`,value:(0,u.pctLabel)(A.rate),detail:A.empty?void 0:`${A.count} cancelled out of ${A.of} bookings`,change:(0,u.changeWords)((0,u.changePct)(A.rate,H.rate),D),empty:"No bookings in this period"}),(0,f.jsx)(w,{testID:"insights-covers",label:`Covers \xb7 ${oe}`,value:_.empty?null:String(_.total),detail:_.empty?void 0:'today'===D?V>0?`${V} more ${1===V?'cover':'covers'} booked for later today`:'No more bookings for later today':`${_.walkIns} walk-in \xb7 ${_.bookings} booked`,change:(0,u.changeWords)((0,u.changePct)(_.empty?null:_.total,O.empty?null:O.total),D),empty:"No covers yet in this period"}),(0,f.jsx)(w,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${oe}`,value:(0,u.pctLabel)(ae.rate),detail:ae.empty?void 0:`${ae.count} of ${ae.of} identifiable seated or finished parties had visited before${te?` (visits on record from ${(0,u.ukDay)(te)})`:''}`,change:(0,u.changeWords)((0,u.changePct)(ae.rate,ne.rate),D),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(w,{testID:"insights-reviews",label:`Reviews \xb7 ${oe}`,value:ie.empty?null:`${ie.avg} / 5`,detail:ie.empty?void 0:`Average of ${ie.count} published review${1===ie.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(w,{testID:"insights-tips",label:`Tips (team total) \xb7 ${oe}`,value:(0,u.moneyGbp)((0,u.completeTotal)(J,J.tips)),detail:null==J.tips?void 0:N&&null!=se.pct?`${J.days} cash-up day${1===J.days?'':'s'} \xb7 ${(0,u.pctLabel)(se.pct)} of takings on the ${se.days} day${1===se.days?'':'s'} with takings`:`${J.days} cash-up day${1===J.days?'':'s'}`,change:J.missing||K.missing?null:(0,u.changeWords)((0,u.changePct)(J.tips,K.tips),D),empty:J.missing?(0,u.missingWords)(J.missing,'tips figure',J.missingDates):'No tips entered in this period'}),N?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(w,{testID:"insights-takings",label:`Takings \xb7 ${oe}`,value:(0,u.moneyGbp)(z.gross),detail:null==z.gross?void 0:`Card + cash \u2212 card tips, from ${z.days}${z.missing?` of ${z.days+z.missing}`:''} confirmed cash-up day${z.days+z.missing===1?'':'s'}${z.missing?`. ${(0,u.takingsMissingWords)(z.missingDates)}`:''}`,change:z.missing||U.missing?null:(0,u.changeWords)((0,u.changePct)(z.gross,U.gross),D),empty:z.missing?(0,u.missingWords)(z.missing,'card or cash total',z.missingDates):'No takings entered in this period'}),(0,f.jsx)(w,{testID:"insights-sph",label:`Spend per head \xb7 ${oe}`,value:(0,u.moneyGbp)(Y.sph),detail:null==Y.sph?void 0:`\xa3${Y.gross.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})} takings \xf7 ${Y.covers} seated or finished covers, on ${Y.days} day${1===Y.days?'':'s'} with both${Y.noCovers?`. ${Y.noCovers} day${1===Y.noCovers?'':'s'} with takings and no Covers (a function, say) count${1===Y.noCovers?'s':''} in takings, not here`:''}`,change:(0,u.changeWords)((0,u.changePct)(Y.sph,q.sph),D),empty:Y.noCovers?'Spend per head needs a day with both takings and seated or finished Covers':'No takings entered, so no spend per head'}),(0,f.jsx)(w,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${oe}`,value:(0,u.pctLabel)(Z.pct),detail:null!=Z.pct?`${(0,u.moneyGbp)(Z.labour)} signed-off wages \xf7 ${(0,u.moneyGbp)(Z.gross)} takings, on the ${Z.days} day${1===Z.days?'':'s'} with takings${z.missing?`. ${z.missing} cash up${1===z.missing?'':'s'} with no card or cash total left out`:''}${Z.awaiting?`. ${Z.awaiting} shift${1===Z.awaiting?'':'s'} on those days still need${1===Z.awaiting?'s':''} signing off, not counted yet`:''}`:void 0,change:(0,u.changeWords)((0,u.changePct)(Z.pct,ee.pct),D),empty:j||Object.keys(C).length?null==Z.gross?'Not enough data: no cash up in this period has a card or cash total':'Not enough data: no signed-off hours with a pay rate on the days with takings':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(o.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-not-shown",children:(0,f.jsx)(o.Muted,{center:!0,children:u.NOT_SHOWN_YET})})]})};var e,s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=(e=a)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),y=_r(d[10]),v=_r(d[11]),$=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function w({testID:e,label:s,value:t,detail:a,change:r,empty:l}){const c=!!r&&r.startsWith('Up'),h=!!r&&r.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.Muted,{center:!0,children:s}),null==t?(0,f.jsx)(o.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:l}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.T,{testID:`${e}-value`,weight:"semibold",size:y.font.hero,colour:y.colours.gold,center:!0,children:t}),a?(0,f.jsx)(o.Muted,{center:!0,children:a}):null,r?(0,f.jsx)(o.T,{testID:`${e}-change`,center:!0,colour:c?y.colours.goldLight:h?y.colours.muted:y.colours.text,children:r}):null]})]})})}},1509,[1467,17,85,777,858,1008,876,1055,1468,899,804,1242,1243,1057,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]})}},1510,[805,1420,812,822,843,1511,1439,1489,1228,841,1263,899,1512,1514,1440,17,1098,1497,13,385,85,864,1281,777,858,876,851,866,1105,1252,863,804,1184,1057,1139,869,1458,853,1026,1155,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)},1511,[843,17,85,777,845,851,1154,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)}}})]})}},1512,[899,17,264,219,85,1281,777,1260,1263,804,1513,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},1513,[17,219,85,777,1260,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'})})}},1514,[805,1420,17,85,777,851,1260,1261,1262,899,1263,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}),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'}]},1515,[812,891,779,869,1217,17,378,219,385,278,85,831,777,1098,858,876,1516,1520,804,1057,1071,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]}})})},1516,[1517,1519,1518]); +__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)}},1517,[843,1518]); +__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'}},1518,[]); +__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}},1519,[1517,1218]); +__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},1520,[869,824,831,834]); +__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})}},1521,[17,1212,1157,1213,1225,1057,1175,847,856,993,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'},1522,[17,85,777,899,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=v,_e.SmsBubble=C,_e.AlertSettings=function({go:e}){const{rid:s}=(0,T.useCtx)(6e4),t=(0,p.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,p.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,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,k.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,k.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>p.useAlerts.getState().setPrefs({muted:!e})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,y.chime)('bright')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,y.lowChime)(.6)})]}),(0,k.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,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,k.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),p.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindChip,{kind:e,size:30}),(0,k.jsx)(c.default,{style:{flex:1},children:(0,k.jsx)(h.Toggle,{label:p.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>p.useAlerts.getState().setType(e,s)})})]},e))]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,k.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,k.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,k.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${p.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,p.sendTestAlert)(s,e)},e))})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,k.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,k.jsx)(h.Muted,{children:r}),(0,k.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>p.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,k.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,p.requestSystemPermission)()),p.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,p.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,k.jsx)(h.Muted,{children:(0,p.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,k.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,k.jsx)(w.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{gap:10,children:[(0,k.jsx)(u.KindIcon,{kind:"email"}),(0,k.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,k.jsx)(h.Badge,{kind:"neutral",label:p.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,k.jsx)(h.Muted,{children:p.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${p.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,k.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,T.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,j.templatesFor)(r),[r]),p=(0,x.useAssistant)(e=>e.enabled)&&b.ASSISTANT_UI,[y,w]=(0,n.useState)('booking'),[A,M]=(0,n.useState)('sms'),B=u[y],I=s=>m.useStore.getState().setTemplate(e,y,s),R=Object.fromEntries(j.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===y?(0,j.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,j.bookingVars)({...S,date:o},s),N=(0,j.toGsm)((0,j.fill)(B.sms,L.sms)),_=(0,j.fill)(B.subject,L.email),D=(0,j.emailHtml)((0,j.fillEmailText)(B.body,L.email),{venue:s.name,preheader:_}),O=!!r?.[y],V=s.settings;return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:j.PREVIEW_BANNER}),(0,k.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,k.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(j.DEFAULT_TEMPLATES).map(e=>(0,k.jsx)(h.Chip,{label:j.TEMPLATE_LABEL[e].title,selected:y===e,onPress:()=>w(e)},e))}),(0,k.jsx)(h.Muted,{children:j.TEMPLATE_LABEL[y].when}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,k.jsxs)(h.Muted,{children:[(0,j.smsParts)(N).chars," characters"]})]}),(0,k.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:B.sms,onChangeText:e=>I({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,j.smsParts)(N).chars>300?(0,k.jsx)(h.T,{size:13,colour:f.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,k.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:B.subject,onChangeText:e=>I({subject:e}),style:h.styles.input}),(0,k.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,k.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:B.body,onChangeText:e=>I({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,k.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[p?(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>I(P(B))}):null,O?(0,k.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,y,null)}):null]}),p?(0,k.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,k.jsxs)(h.Muted,{children:["Placeholders: ",j.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:"Text",selected:'sms'===A,onPress:()=>M('sms')}),(0,k.jsx)(h.Chip,{label:"Email",selected:'email'===A,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,k.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,k.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===y?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===A?(0,k.jsx)(C,{text:N,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),_]}),(0,k.jsx)(v,{html:D})]})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,k.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,k.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:V.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,k.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!V.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,k.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,T.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),b=t.filter(e=>'all'===l||e.channel===l);return(0,k.jsxs)(c.default,{style:{gap:10},children:[(0,k.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:f.colours.gold,borderRadius:12,padding:12},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:f.colours.gold,children:(0,j.isLive)()?'Live: messages are sent through your text and email service.':j.PREVIEW_BANNER}),(0,j.isLive)()?null:(0,k.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,k.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,k.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),b.length?null:(0,k.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),b.map(e=>(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(h.Row,{gap:6,children:[(0,k.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,k.jsxs)(h.T,{weight:"semibold",children:[A[e.kind]," \xb7 ",e.ref]})]}),(0,k.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,k.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,k.jsx)(h.T,{size:13,colour:'sent'===e.status?f.colours.ok:'failed'===e.status?f.colours.red:f.colours.amber,children:(0,j.statusLabel)(e)})]}),'sms'===e.channel?(0,k.jsx)(C,{text:e.body}):u===e.id?(0,k.jsxs)(c.default,{style:{gap:6},children:[(0,k.jsxs)(h.T,{size:14,children:[(0,k.jsx)(h.T,{size:14,colour:f.colours.muted,children:"Subject: "}),e.subject]}),(0,k.jsx)(v,{html:e.html??'',height:560})]}):(0,k.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,k.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]),k=_r(d[18]);function v({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 C({text:e,to:t}){const l=(0,j.smsParts)(e);return(0,k.jsxs)(c.default,{style:{gap:4},children:[t?(0,k.jsxs)(h.Muted,{children:["To ",t]}):null,(0,k.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,k.jsx)(h.T,{size:15,children:e})}),(0,k.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const S={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 P(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 A={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1523,[813,812,822,17,219,385,85,777,1230,858,1520,1214,848,1232,1018,804,1027,1057,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:n,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,b=n.settings,x=(0,r.bookingRulesOf)(n),f=(0,o.usePlan)(g),j=(f?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...b.bookingRules??{},...x,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(n),M=(0,d.depositOf)(b),R=b.reservables??(0,i.reservablesOf)(n),O=(0,r.accessGuideOf)(n),[I,A]=(0,t.useState)(null),D=(e,t)=>T({largeGroups:x.largeGroups.map((n,s)=>s===e?{...n,...t}:n)});return(0,y.jsxs)(s.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."}),I?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:I}):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:b.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)(n)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(n)} 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."}),x.largeGroups.map((e,t)=>(0,y.jsxs)(s.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=>D(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>D(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=>D(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:x.largeGroups.filter((e,n)=>n!==t)})}):null]},t)),x.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=x.largeGroups[x.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...x.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:j.map(e=>{const t=x.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(x.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:x.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)(x,n.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(x.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:j.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:x.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(x.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:x.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!==b.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:x.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),x.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,x.onlineTableMins.map((e,t)=>(0,y.jsxs)(a.Muted,{center:!0,testID:`rules-table-min-${t}`,children:[(0,r.onlineTableMinLine)(e),". Staff can still book them for fewer."]},t)),(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:b.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:M.on&&M.perPersonPence>0?`${w(M.perPersonPence)} per adult for ${M.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),R.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:x.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:x.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:x.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:x.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:x.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:x.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}),A('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:n}=(0,k.useCtx)(6e4),o=T(n),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,b.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,f.isSupabaseConfigured)())return;let e=!0;try{(0,x.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:n})=>{e&&!n&&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)(s.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,f.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,x.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:j.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),n=_r(_d[1]),s=(e=n)&&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]),b=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),j=_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(b.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()},1524,[17,85,777,858,998,1079,1055,841,1105,1252,889,876,920,899,928,971,804,1057,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)})]})]})}},1525,[17,385,85,777,876,1000,851,1001,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]})}},1526,[17,219,385,85,409,777,804,1378,857,1382,863,899,1383,1057,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})},1527,[820,896,1456,17,219,85,777,816,876,895,1000,897,899,1528,804,880,1163,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'}},1528,[]); +__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])},1529,[17,85,777,804,1435,1511,1057,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=w,_e.HelpPage=function({go:e}){const[s,o]=(0,a.useState)(''),[r,h]=(0,a.useState)(null),[p,x]=(0,a.useState)(null),w=(0,a.useMemo)(()=>[...c.HELP,...m],[]),j=(0,a.useMemo)(()=>s.trim()?(0,u.searchHelp)(w,s,10).map(e=>e.a):w.filter(e=>!r||e.topic===r),[s,r,w]);return(0,f.jsxs)(i.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(i.default,{style:[l.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(l.T,{colour:y.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:o,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:y.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(n.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>o('')}):null]}),s?(0,f.jsx)(l.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)(l.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(l.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,n)=>(0,f.jsx)(b,{a:t,go:e,open:p===t.id||!!s&&0===n&&null===p,onToggle:()=>x(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(l.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",colour:y.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(l.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(l.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=function({go:e}){const{rid:t,today:s}=(0,x.useCtx)(6e4),n={rid:t,today:s,go:(t,s)=>e(t,s??null)},[o,r]=(0,a.useState)(''),[h,u]=(0,a.useState)(null),[m,b]=(0,a.useState)(null),C=async()=>{const e=o.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,n);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...j(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(i.default,{testID:"ask-assistant",children:(0,f.jsxs)(l.Card,{highlight:y.colours.gold,children:[(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(i.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(l.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:o,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:C,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(l.Button,{label:"Ask",testID:"assistant-ask",disabled:!o.trim(),onPress:C,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(l.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)(l.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(k,{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,n,!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,m?(0,f.jsxs)(i.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(l.Banner,{kind:'done'===m.kind?'success':'error'===m.kind?'warn':'demo'===m.kind?'demo':'info',title:m.text}),m.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>w(s,e)}):null]},t)})]}):null,(0,f.jsx)(l.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),o=e(_r(d[4])),i=e(_r(d[5])),l=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),y=_r(d[12]),x=_r(d[13]),f=_r(d[14]);const m=[{id:'ai-assistant-pairing',kind:'faq',topic:'Accounts',title:'Can I connect my own AI assistant?',keywords:['assistant','ai','pair','pairing','grok','bot','unpair','approve','draft','log'],body:'AI assistant ready: connect your own AI assistant, such as Grok Bot, to your owner app. In the connected assistant, it can answer questions about your venue and give advice from the venue data it is allowed to look up. It can draft changes for you to approve, and change your settings once you approve (except plan and billing, staff sign-in links, PINs, the kitchen unlock code, and connected accounts). You can switch it off at any time, and everything it does is logged, including look-ups. Open More \u203a Account \u203a Assistants, as an owner, on Full Restaurant Pro, SuperPro or the early adopter offer. It is not included with Customer & Takeaway App, and there is no AI assistant on the Display app.',showMe:{tab:'more',page:'assistants',target:{testID:'assistants-page'},hint:'Pair, switch off or unpair an assistant here. Owners only.'}},{id:'customer-support',kind:'faq',topic:'Accounts',title:'How do I contact CoverCharge support?',keywords:['support','customer support','help','email','picture','photo','screenshot','contact','covercharge'],body:'Customer support is at the very bottom of Home, and at the bottom of More, as an owner. Write a message, attach one picture if you like (a photo or a screenshot), and tap Send to CoverCharge. It is sent with your venue name, your name and email, and the app version. You will see \u201cSent. We\u2019ll reply by email.\u201d if it went through, or an error with a way to try again. There is no Customer support on the Display, Staff, Front of House or Head Chef apps.',showMe:{tab:'more',page:'support',target:{testID:'customer-support'},hint:'Write a message, attach a picture if you like, and send it to CoverCharge. Owners only.'}},{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:'In the Managers app go to More \u203a Run the day \u203a Display settings 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. There is no wipe or unpair button on the Display itself. To switch a Display off, go to Settings \u203a Displays and choose Switch off.',showMe:{tab:'more',page:'displaysettings',target:{testID:'wipe-setting'},hint:'Sign out and wipe is in Display settings, in the Managers app only.'}}];function w(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 b({a:e,go:t,open:s,onToggle:n}){return(0,f.jsx)(i.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(o.default,{accessibilityRole:"button",onPress:n,children:(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(i.default,{style:{flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(l.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(l.T,{colour:y.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(i.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:y.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(l.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(l.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:(0,f.jsx)(l.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>w(e,t)})}):null]})})}function j(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function k({p:e,today:t,onChange:n,onConfirm:a,onCancel:o}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>n({...e.params,[t]:s}),x=e.action,m=e.params,w=x.params.every(e=>!e.required||void 0!==m[e.name]&&''!==m[e.name]);return(0,f.jsxs)(i.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?y.colours.red:y.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':y.colours.okBg},children:[(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[x.risk]}),(0,f.jsx)(l.T,{weight:"semibold",style:{flex:1},children:x.title})]}),x.form&&'add_walkin'===x.id?(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Covers",value:void 0===m.covers?'':String(m.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Table (optional)",value:void 0===m.table?'':String(m.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,x.form&&'add_rota_shift'===x.id?(0,f.jsxs)(i.default,{style:{gap:6},children:[(0,f.jsx)(l.Muted,{size:12,children:"Who"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(l.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:m.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(i.default,{style:{flex:1.3},children:(0,f.jsx)(l.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(m.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"Start (24h)",value:String(m.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(i.default,{style:{flex:1},children:(0,f.jsx)(l.Field,{label:"End (24h)",value:String(m.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(l.T,{children:w?x.preview(m,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(l.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(l.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(l.Row,{gap:8,children:[(0,f.jsx)(l.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!w,onPress:a,style:{flex:1}}),(0,f.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:o,style:{flex:1}})]})]})}},1530,[812,1033,779,17,385,85,777,876,1481,1531,1532,1533,804,1057,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.','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:'guest-change-link',kind:'faq',topic:'Bookings',title:'Can guests change or cancel their own booking?',keywords:['change','cancel','link','email','guest','move','booking'],body:'Yes. The confirmation email has a "Change or cancel your booking" link for that one booking, with "Or call us on (your number) and quote your booking details." underneath. Guests can change the date, time or party size within your online booking rules, or cancel after confirming. Bookings with a deposit say "please call us" instead. Takeaway orders can\u2019t be changed or cancelled by the guest, and their email has no link. You see every change on the Display and in Managers, marked as changed by the guest. The link stops working at the booking time.'},{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:'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 takings \xf7 Covers, by day and by week. Takings are card + cash \u2212 card tips from the cash up, worked out for you (a prepaid function with no card or cash uses its Gross). 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.'},{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.'}],o=t=>a.find(a=>a.id===t)},1531,[]); +__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}},1532,[]); +__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}},1533,[1534,1100,843,1535,1536,876,858,998,1481,1531,1532,1538,1537,1540,1541,996,997]); +__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))}}]},1534,[1064,1063,1023]); +__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.`)}}]},1535,[896,1100,820,843,1121,1098,1115,922,858,816,998,895,897,1010,876,1067,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]),n=_r(_d[3]),r=_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)=>r.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(),n=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(n){const e=Number(/\d/.test(n[1])?n[1]:n[2]),a=L.indexOf(/\d/.test(n[1])?n[2]:n[1]);let r=Number(t.slice(0,4));return`${r}-${A(a+1)}-${A(e)}`e.active)){const n=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),r=Math.min(...n.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));r<1/0&&a.push({s:e,at:r})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>r.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(),n=U(e);if(!n.length)return;const r=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(r)return n.find(e=>e.number===Number(r[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=n.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===n.length?n[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const r=a.useStore.getState(),i=r.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=n.useFloor.getState(),c=d.plans[e]??(0,n.seedPlan)(e),h=r.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,r.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 n=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return n?`Seat ${Y(a)}, at table ${n}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const r=z(a.rid,e.who);if(!r)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,r.partySize);return i?(await t.repo.waitlist.setStatus(r.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,r.partySize,i,`From waitlist #${r.number}`),(0,n.tablesOf)(i).forEach(e=>n.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${r.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=r.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),n=j(String(t??''),e.today);return n?a.find(e=>e.date===n):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(),n=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(n){const e=j(n[1],t),a=j(n[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!n||e.kind===n)),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 ne(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),n=new Date(a+'T00:00:00').getTime(),r=n+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=n&&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>=n&&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)()),n=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),r=(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=>r.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),n):[];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 n;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(n?.s??0)&&(n={m:t,s:e})}return n?.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 n=z(a.rid,e.who);return n?(await t.repo.waitlist.setStatus(n.id,'removed'),`Done: number ${n.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,r)=>{const i=z(r.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===r.rid);return n.useFloor.getState().logSms(r.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?r.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(r.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),n=E(e.with);return n&&n.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(n.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),n=E(e.with);return a&&t.whoId?n&&n.id!==t.whoId?(r.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:n.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(n.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)())),n=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:n&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(n[1])?n[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=r.useOwner.getState().shifts.find(e=>e.id===t.shiftId),n=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${n}\u2019s swap with ${i}`:t.toId?`${i} covering ${n}`:`${n}\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 ${n}\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=r.useOwner.getState(),n=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)}${n?` (${M[n.day]} ${R(n.start)}\u2013${R(n.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 n=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: ${n.n} checks, ${n.bad} out of range${n.bad?`, ${n.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:n}=ne(t.today,t),r=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(r)return`This week is already signed off by ${r.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${n.entries} checks, ${n.outOfRange} out of range, ${n.actions} with an action, diary signed ${n.daysSigned} of 7 days.`;return n.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:n}=ne(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':n.actions!0),note:'Signed by voice: yes to all.',summary:n}),'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),n=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${n}; 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)),n='Near miss'===a.category,r=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(r)}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??'')||(n?'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:n,rem:r}=se(t,e.task);return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?`${_(n.text)} is already ticked today.`:`Tick off today\u2019s task ${_(n.text)}?`:r?`Mark the reminder ${_(r.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:n,rem:r}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return n?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,n.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,n.id,a,i),`Done: ${_(n.text)} ticked.`):r?(c.useReminders.getState().markDone({rid:t.rid,reminderId:r.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),r=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=n?.sections.find(e=>r.includes(e.toLowerCase())||r.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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=String(e.section??n?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${r} 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 n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),r=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(r)||r<=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??n?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:r,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 n=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 n?{dish:n[1],field:'description',value:n[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 n=de(t.rid,e.dish),r=String(e.value??'').trim();return n?r.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(n.id,'name'===e.field?{name:r}:{description:r}),'name'===e.field?`Done: renamed to ${r}.`:`Done: description of ${n.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 n=(0,$.findCard)(t.rid,a.dish);return n?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${n.dish}\u2019s recipe card?${n.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)),n=a&&(0,$.findCard)(t.rid,a.dish);return a&&n?(await(0,y.recipeCards)().update(n.id,{ingredients:[...n.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 ${n.dish}.${n.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,n=String(e.step??'').trim();return!a||n.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,n]},{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],n=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),r=/\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:r,reason:n?.[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 n=e.action??'in',r=(0,g.managerClockAction)(n,{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 r.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[n]} at ${D()}.${r.warn?' '+r.warn:''}`:'Nothing changed: '+r.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 n=h.useCashUp.getState(),r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,r?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(n.tips.filter(e=>e.rid===t.rid),n.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: 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 n='yesterday'===e.day?(0,l.ymdOf)(a):e.day,r=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!n||e.date===n)).sort((e,t)=>t.date.localeCompare(e.date)),i=r[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: takings ${fe((0,p.tillTakingsOf)(i.vals))} (card + cash \u2212 card tips), tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:n?`There\u2019s no cash-up for ${(0,$.niceDay)(n)}.`:'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 r='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,n.tablesOf)(a).forEach(e=>n.useFloor.getState().setLive(t.rid,e,{note:r||void 0})),r?`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 n=(0,$.appNow)();return r.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(n)} ${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',n=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),r=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:n?.[1]?.trim(),time:r?(0,$.hm)(r[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??''),n=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(n)}, ${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(),n=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(n))return'Nothing changed: I need the wording and a time like 21:00.';const r=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:r,time:n,audience:e.audience??'all'}),'Done: reminder added.'}}]},1536,[820,858,816,998,876,1003,1014,1015,927,926,1008,839,1034,1035,1036,1004,1067,867,1076,995,854,1537,1535]); +__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.'}}]},1537,[820,891,1100,843,1140,1263,858,816,998,1003,910,846,845,1076,1077,995,1004,851,1538,1539]); +__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)}))},1538,[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)}))},1539,[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)])},1540,[816,876,910,851,1537,1017,1071]); +__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))'},1541,[]); +__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,u.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:u.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:u.VOICE_ROLE_LABEL[s],value:(0,u.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,h.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:p}=(0,f.useCtx)(6e4),u=(0,r.useDrafts)(e=>e.drafts),h=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=u.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),D='owner'===p||'manager'===p,C=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:r.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&&D?(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'})}),C(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${C(e).name} ordering`,onPress:()=>{t.default.openURL(C(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:"Drafts saved earlier (bookings, supplier shopping lists, offers, events, specials, messages and payments) wait 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."}),D?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:()=>{h(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,p.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,p.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. 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]),r=_r(_d[6]),l=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),h=_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'}}},1542,[17,362,85,777,804,1477,1538,1489,1539,1543,1217,1544,1057,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return s}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(f(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(f(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),s=(e,n,t)=>!1!==e[n]?.[t],f=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1543,[824,831,834]); +__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])},1544,[17,85,777,804,1545,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.'},1545,[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}},1546,[17,779,85,777,845,1260,1547,1548,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'},1547,[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()})},1548,[899,1547,1263]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:l,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,o.useCashUp)(e=>e.cashUps),k=(0,o.useCashSettings)(e),w=(0,d.useNightlyPrefs)(s=>s.email[e]??!1),T=(0,d.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(s=>s.rid===e&&s.on).map(e=>e.name),[N,U]=(0,s.useState)((0,u.addDaysYmd)(v,-1)),P=(0,u.cashFieldsForRecord)(k.cashFields,(0,u.cashUpRecordFor)(e,l.settings.cashUpRecord)),R=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:P,soldOut:C}),_='anchorage'!==e&&w,D=[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:D.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:()=>U(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:R.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(R.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(R.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(R.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:R.takings}),(0,j.jsx)(x,{label:"Tips",value:R.tips}),(0,j.jsx)(x,{label:"Takings last week",value:R.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:R.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:R.soldOut.length?R.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),R.cashUp.length?R.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:_,onChange:s=>T(e,s)}):null]})};var e,s=_r(_d[0]),l=_r(_d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),d=_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:s})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${s}`,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:s})]})},1549,[17,85,777,858,1008,1550,891,839,1551,1020,804,1057,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}))},1550,[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.tillTakingsOf)(k.vals):null,N=(0,l.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:s(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(y),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(O?(0,t.tillTakingsOf)(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]),l=r(d[2]);const s=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?s(t):String(t);function u(t,l,u){const c=[];for(const f of l){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const l=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==l?'Not entered':s(l)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!l.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const l=(0,n.expectedCashInDrawer)(t);null!=l&&c.push({label:'Expected cash in the drawer',value:s(l)})}return c}},1551,[839,1009,1469]); +__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.SupportChatPage=function(){const{r:e,me:f,meId:x}=(0,h.useCtx)(6e4),[j,v]=(0,s.useState)(''),[C,I]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[R,D]=(0,s.useState)('idle'),[L,P]=(0,s.useState)(''),[k,B]=(0,s.useState)(''),[_,T]=(0,s.useState)('');(0,s.useEffect)(()=>{(0,p.signedInEmail)().then(B)},[]);const E=async e=>{T('');try{const t=await(0,c.capturePlatingPhoto)(e);t&&(I(t),D(e=>'sent'===e?'idle':e))}catch(e){T(e instanceof Error?e.message:'Could not add that picture.')}},H=async()=>{const t=j.trim();if(!t||w)return;S(!0),P(''),D('idle');const s=await(0,p.writeSupportRequest)({venueName:e.name,body:t,fromName:f.replace(' (example)',''),fromEmail:k,staffRef:x||'',appVersion:u.APP_VERSION,photoDataUrl:C?.dataUrl??null});if(S(!1),s.ok)return v(''),I(null),D('sent'),void P(b);D('error'),P(s.message)};return(0,y.jsxs)(l.default,{testID:"customer-support",style:{gap:12,alignItems:'center',width:'100%',paddingBottom:8},children:[(0,y.jsx)(o.T,{center:!0,weight:"bold",colour:n.colours.gold,accessibilityRole:"header",children:"Customer support"}),(0,y.jsx)(o.Muted,{center:!0,children:"Send a message to CoverCharge. You can attach one picture, such as a photo or a screenshot. We'll reply by email."}),'sent'===R?(0,y.jsx)(l.default,{testID:"support-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:b,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"success",title:b})}):null,'error'===R?(0,y.jsx)(l.default,{testID:"support-error",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:L,style:{width:'100%'},children:(0,y.jsx)(o.Banner,{kind:"danger",title:L})}):null,(0,y.jsx)(t.TextInput,{testID:"support-message",accessibilityLabel:"Your message to CoverCharge",value:j,onChangeText:e=>{v(e),'sent'===R&&D('idle')},placeholder:"Write your message",placeholderTextColor:n.colours.muted,multiline:!0,style:{width:'100%',minHeight:120,borderWidth:1,borderColor:n.colours.border,borderRadius:12,padding:12,color:n.colours.text,textAlign:'center'}}),C?(0,y.jsxs)(l.default,{testID:"support-photo-preview",style:{alignItems:'center',width:'100%',gap:8},children:[(0,y.jsx)(r.default,{source:{uri:C.dataUrl},style:{width:240,height:180,borderRadius:12,backgroundColor:n.colours.surface2},accessibilityLabel:"Attached picture preview"}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Remove picture",accessibilityLabel:"Remove the attached picture",testID:"support-photo-remove",onPress:()=>I(null),style:{minHeight:48}})]}):(0,y.jsxs)(l.default,{style:{width:'100%',gap:8,alignItems:'center'},children:[(0,y.jsx)(o.Button,{kind:"secondary",label:"Take a photo",accessibilityLabel:"Take a photo to attach",testID:"support-photo-camera",onPress:()=>{E('camera')},style:{minHeight:48,width:'100%'}}),(0,y.jsx)(o.Button,{kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a picture or screenshot from your gallery",testID:"support-photo-gallery",onPress:()=>{E('library')},style:{minHeight:48,width:'100%'}})]}),_?(0,y.jsx)(o.Muted,{center:!0,testID:"support-photo-error",children:_}):null,(0,y.jsx)(o.Button,{testID:"support-send",label:"Send to CoverCharge",accessibilityLabel:"Send to CoverCharge",disabled:!j.trim()||w,onPress:()=>{H()},style:{minHeight:56,width:'100%'}}),w?(0,y.jsx)(l.default,{accessibilityLiveRegion:"polite",style:{width:'100%'},children:(0,y.jsx)(o.Muted,{center:!0,testID:"support-sending",children:"Sending\u2026"})}):null]})};var t=_r(d[0]),s=_r(d[1]),r=e(_r(d[2])),l=e(_r(d[3])),o=_r(d[4]),n=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),y=_r(d[10]);const b="Sent. We'll reply by email."},1552,[812,17,319,85,777,804,1082,978,1553,1057,8]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPPORT_BUCKET",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SUPPORT_SEND_FAILED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SUPPORT_SIGN_IN",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SUPPORT_NO_EMAIL",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SUPPORT_PHOTO_FAILED",{enumerable:!0,get:function(){return l}}),e.writeSupportMessage=async function(o){if(!t.RELEASE.supportSync)return{ok:!1,message:n.SUPPORT_NOT_SENT};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:n.SUPPORT_NOT_SENT};const c=u.useSync.getState().venueId;if(!c)return{ok:!1,message:`${n.SUPPORT_NOT_SENT} Sign in and try again.`};try{const t=(0,i.getSupabase)(),{error:s}=await t.from('support_messages').insert({venue_id:c,body:o.text,from_name:o.from,staff_ref:o.staffRef||null});return s?{ok:!1,message:n.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:n.SUPPORT_NOT_SENT}}},e.writeSupportRequest=async function(t){if('undefined'!=typeof globalThis&&globalThis.__CC_SUPPORT_FAKE_SEND)return{ok:!0,id:'preview-test',emailed:!0};const n=t.body.trim().slice(0,4e3),S=t.fromName.trim().slice(0,80),y=t.fromEmail.trim().slice(0,254),P=t.venueName.trim().slice(0,120);if(!n||!S||!P)return{ok:!1,message:f};if(!y||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y))return{ok:!1,message:m};if(!(0,s.isSupabaseConfigured)())return{ok:!1,message:p};const b=u.useSync.getState().venueId;if(!b)return{ok:!1,message:p};const T=globalThis.crypto?.randomUUID?.()??`00000000-0000-4000-8000-${Date.now().toString(16).padStart(12,'0')}`,O=(0,i.getSupabase)();let h=null;if(t.photoDataUrl)try{const n=_(t.photoDataUrl);h=`${b}/${T}.jpg`;const{error:o}=await O.storage.from(c).upload(h,n,{contentType:'image/jpeg',upsert:!1});if(o)return{ok:!1,message:l}}catch{return{ok:!1,message:l}}const E={id:T,venue_id:b,venue_name:P,body:n,from_name:S,from_email:y,staff_ref:t.staffRef||null,app_version:(t.appVersion||o.APP_VERSION).slice(0,40),photo_path:h},{error:N}=await O.from('support_requests').insert(E);if(N)return{ok:!1,message:f};let U=!1;try{const t=await O.functions.invoke('send-support-email',{body:{request_id:T}}),n=t.data;U=!t.error&&!!n?.sent}catch{U=!1}return{ok:!0,id:T,emailed:U}},e.signedInEmail=async function(){if(!(0,s.isSupabaseConfigured)())return'';try{const{data:t}=await(0,i.getSupabase)().auth.getUser();return(t.user?.email??'').trim()}catch{return''}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),i=r(d[4]),u=r(d[5]);const c='support-photos',f='Could not send. Check your connection and try again.',p='Could not send. Sign in and try again.',m='Your sign-in has no email. Sign in again and try again.',l='Could not attach the picture. Try a smaller photo, or send without a picture.';function _(t){const n=/^data:([^;]+);base64,(.+)$/.exec(t);if(!n)throw new Error('bad picture');const o=atob(n[2]),s=new Uint8Array(o.length);for(let t=0;t{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{}}},1554,[17,264,219,85,777,812,804,899,1430,1188,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+'},1555,[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 ']]},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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:te,height:se}=(0,a.default)(),[oe,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(!1),[le,ae]=(0,t.useState)(!1),[de,ce]=(0,t.useState)(''),[ue,ge]=(0,t.useState)(!1),[he,pe]=(0,t.useState)(!1),[be,fe]=(0,t.useState)(!1),[me,xe]=(0,t.useState)(!1),ke=(0,t.useRef)(null),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(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,M.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const Ce=(0,K.useTakingsAllowed)(s),ve=(0,t.useCallback)(e=>{const t=(0,A.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),De=(0,t.useMemo)(()=>(0,V.buttonsFor)({takings:Ce,pageOk:ve}),[Ce,ve]),Ie=oe?(0,V.tabsFor)(oe.btn,{takings:Ce,pageOk:ve}):[],Se=(0,t.useCallback)((e,t)=>{const s=(0,V.tabsFor)(e,{takings:Ce,pageOk:ve});s.length&&(ie(!1),ae(!1),ce(''),ne({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[Ce,ve]),Te=De.find(e=>'settings'===e.id),Re=(0,t.useCallback)(e=>{const t=De.find(t=>t.pages.some(t=>t.id===e));t?Se(t,e):Te&&ve(e)&&(ie(!1),ae(!1),ce(''),ne({btn:Te,tab:'@desk-settings',page:e}))},[De,Se,Te,ve]),Oe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Re(t);else{if('bookings'===e){const e=De.find(e=>'bookings'===e.id);return void(e&&Se(e,'@bookings'))}if('chat'===e){const e=De.find(e=>'chat'===e.id);return void(e&&Se(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Te&&Se(Te):ne(t=>({btn:t?.btn??De[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else ne(null)},[De,Se,Re,Te]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Oe}),()=>T.useVoiceNav.setState({go:null})),[Oe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Oe('bookings'):'chat'===e?Oe('chat'):Oe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Pe=!oe||De.some(e=>e.id===oe.btn.id)&&Ie.some(e=>e.id===oe.tab)&&(!oe.page||ve(oe.page));(0,t.useEffect)(()=>{if(!Pe){const e=setTimeout(()=>ne(null),0);return()=>clearTimeout(e)}},[Pe]);const Le=oe?.page?(0,A.pageFor)(oe.page):void 0,We=oe?(0,_.deskCopy)(Le?.title??oe.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${We} \xb7 The Anchorage \xb7 CoverCharge for desktop`),we.current?.scrollTo?.({y:0,animated:!1}),oe){const e=setTimeout(()=>Y(je.current),80);return()=>clearTimeout(e)}},[We,oe?.tab,oe?.page]),(0,t.useEffect)(()=>{if(le){const e=setTimeout(()=>ke.current?.focus?.(),100);return()=>clearTimeout(e)}},[le]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=q(e.target),s=(0,_.commandKey)(e,t);if('escape'===s){if(le||ue||he||be)return e.preventDefault(),ae(!1),ge(!1),pe(!1),void fe(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return re?(e.preventDefault(),void ie(!1)):void(oe&&(e.preventDefault(),ne(null)))}if(le||ue||he||be||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),ie(!1),void ae(!0);if('help'===s)return e.preventDefault(),void ge(!0);if('filter'===s&&ye.current&&oe)return e.preventDefault(),void ye.current?.focus?.();const o=t?null:(0,_.shortcutIndex)(e);null!=o&&De[o]&&(e.preventDefault(),Se(De[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[le,ue,he,be,re,oe,De,Se]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Oe,globalThis.__deskOpen=(e,t)=>{const s=De.find(t=>t.id===e);s&&Se(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Oe,De,Se]);const Be=(0,t.useMemo)(()=>{const e=de.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De.flatMap(e=>(0,V.tabsFor)(e,{takings:Ce,pageOk:ve}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Se(e,t.id)}))),o=new Set(De.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...A.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,_.deskCopy)(e.title),sub:(0,_.deskCopy)(e.sub??''),run:()=>Re(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[de,De,s,Ce,ve,Se,Re]),He=(0,N.ddmmyyyy)(o),Me=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),Ee=b?(0,B.authorityRole)(b):s,$e=(b?.name??h).replace(' (example)',''),ze='owner'===Ee?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Ae=e=>(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Fe=e=>{const t=(0,A.pageFor)(e);return!t||t.can&&!t.can(s)?(0,X.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,X.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,X.jsx)(t.C,{go:Oe})})};return(0,X.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,X.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>oe?Y(je.current):ie(!0),children:(0,X.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:oe?'Skip to main content':'Open the owner tools menu'})}),(0,X.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,X.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:te,headerExtra:(0,X.jsx)(J,{open:re,onPress:()=>ie(!0)}),subHeader:(0,X.jsx)(Q,{name:$e,access:ze,day:He,at:Me})}),oe&&Pe?(0,X.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,X.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,X.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,X.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:oe.page?'Back to all settings':`Close ${oe.btn.label}, back to the floor plan`,onPress:()=>oe.page?ne({...oe,page:null}):ne(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,X.jsx)(f.T,{weight:"semibold",center:!0,children:oe.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,X.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,X.jsx)(l.default,{ref:je,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,X.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:We})}),(0,X.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,_.deskCopy)(Le?.sub??oe.btn.hint)})]}),(0,X.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,X.jsx)(J,{testID:"desk-menu-button-page",open:re,onPress:()=>ie(!0)})})]}),Ie.length>1&&!oe.page?(0,X.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Ie.map(e=>{const t=e.id===oe.tab;return(0,X.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>ne({btn:oe.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?Z:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,X.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,X.jsx)(i.default,{ref:we,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(!oe||!Pe)return null;if(oe.page)return Fe(oe.page);switch(oe.tab){case'@desk-bookings':return(0,X.jsx)(K.DesktopBookings,{filterRef:ye});case'@desk-hours':return(0,X.jsx)(K.DesktopHours,{go:Oe,filterRef:ye});case'@desk-takings':return Ce?(0,X.jsx)(K.DesktopTakings,{go:Oe}):(0,X.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,X.jsx)(K.DesktopSettings,{open:e=>ne(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,X.jsx)(G.DeskPermissions,{});case'@desk-leavers':return(0,X.jsx)(G.DeskLeavers,{});case'@desk-temps':return Ae((0,X.jsx)(G.DeskTemps,{}));case'@desk-bookinghistory':return Ae((0,X.jsx)(G.DeskCoversHistory,{}));case'@bookings':return(0,X.jsx)(H.Bookings,{go:Oe});case'@chat':return(0,X.jsx)(M.Chat,{go:Oe});case'@noshows':return Ae((0,X.jsx)(W.NoShows,{go:Oe}));case'@orders':return(0,X.jsx)($.Orders,{});case'@forecast':return(0,X.jsx)(E.Forecasts,{go:Oe});default:return Fe(oe.tab)}})()})]}):null]}),(0,X.jsx)(ee,{visible:re,buttons:De,current:oe?.btn.id,W:te,H:se,onClose:()=>ie(!1),onPick:e=>Se(e),onFind:()=>{ie(!1),ae(!0)},onKeys:()=>{ie(!1),ge(!0)},onInstall:()=>{ie(!1),pe(!0)},onSignOut:()=>{ie(!1),fe(!0)}}),le?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ae(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,X.jsx)(p.TextInput,{ref:ke,value:de,onChangeText:ce,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,X.jsx)(l.default,{'aria-live':'polite',children:(0,X.jsxs)(f.Muted,{center:!0,children:[Be.length," pages"]})}),Be.slice(0,60).map(e=>(0,X.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,X.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,X.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ue?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>ge(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,_.SHORTCUTS)((0,F.isMac)()).map(([e,t])=>(0,X.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,X.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,X.jsx)(f.T,{center:!0,children:t})]},e)),(0,X.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,be?(0,X.jsxs)(f.Sheet,{visible:!0,onClose:()=>fe(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,X.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,X.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,X.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>fe(!1),testID:"desk-signout-cancel"}),(0,X.jsx)(f.Button,{label:me?'Signing out\u2026':'Sign out',disabled:me,onPress:async()=>{xe(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,he?(0,X.jsx)(f.Sheet,{visible:!0,onClose:()=>pe(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,X.jsx)(U.DesktopInstallPage,{})}):null,(0,X.jsx)(k.SeatAllergenReminder,{rid:e}),(0,X.jsx)(x.PrintHost,{rid:e}),(0,X.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Oe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,X.jsx)(z.OnboardingHost,{go:Oe}),(0,X.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]);r(d[37]);var F=r(d[38]),_=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]);const q=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Y=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},Z='rgba(201,162,74,0.14)';function J({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,X.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,X.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,X.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,X.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function Q({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,X.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,X.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,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,X.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function ee({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,V.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(()=>Y(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,F.isMac)();return(0,X.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,X.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,X.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,X.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,X.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,X.jsx)(l.default,{style:{width:56}}),(0,X.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,X.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,X.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,X.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,V.deskShortcut)(t,B);return(0,X.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,X.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:Z,alignItems:'center',justifyContent:'center'},children:(0,X.jsx)(G.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,X.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,X.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,X.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,X.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1558,[17,266,347,219,385,278,85,409,19,780,812,779,777,1230,1394,1087,1481,1086,1084,1232,1245,891,876,1032,1489,880,899,804,1340,1559,1057,1419,1161,1483,1485,1474,1458,1487,1555,1557,1565,1566,1567,1570,1573,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))}},1559,[17,266,347,219,385,278,85,409,780,779,1340,1458,1487,1419,1161,1485,1483,1057,1026,777,858,876,863,899,880,804,1560,1561,1562,1563,1564,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1560,[]); +__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])},1561,[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])},1562,[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])},1563,[17,385,1163,1164,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},1564,[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,b=Math.round(1.4*h),k=Math.max(48,Math.min(72,c-2*b-14,l-34));return{panelW:n,colW:l,per:c,circle:k,label:h,lineH:b,icon:Math.round(.44*k),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}],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'},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','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}`},1565,[1560]); +__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)},1566,[]); +__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,f.useOwner)(e=>e.staff),x=(0,f.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)),T=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=T.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,f.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,D.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,m.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,D.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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,D.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,D.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,f]=(0,t.useState)('next7'),[m,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[T,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,D.bookingColumns)(T),[T]),E=(0,t.useMemo)(()=>(0,D.sortRows)((0,D.filterRows)((0,D.bookingsBetween)(r,W,L,m),z,x),z.find(e=>e.key===$),M),[r,W,L,m,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:()=>f(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:m===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:T?'Hide phone numbers':'Show phone numbers',selected:T,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,D.csvName)('bookings',W,L),(0,D.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,D.ddmmyyyy)(W)}${L!==W?` to ${(0,D.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,D.ddmmyyyy)(W)} to ${(0,D.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,D.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${D.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,D.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",D.STATUS_WORD[G.status]??G.status]}),G.phone&&T?(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,f.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,m]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,T]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,f.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,D.ukTime)(e.in),outT:(0,D.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,D.sortRows)((0,D.filterRows)(O.filter(e=>'all'===p||e.status===p),D.HOURS_COLUMNS,y),D.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:m,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,D.csvName)('hours',R,M),(0,D.toCsv)(N,D.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,D.hm)((0,D.totalPaid)(N))} paid \xb7 ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,D.ddmmyyyy)(R)} to ${(0,D.ddmmyyyy)(M)}`,cols:D.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(T(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,D.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.tillTakingsOf)(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:T.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...T.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!T.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,T.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,T.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,T.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]),f=_r(_d[13]),m=_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]),T=_r(_d[23]),D=_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 f.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]}},1567,[17,385,85,409,812,777,1072,1032,1180,1122,1091,858,1008,876,1055,839,889,899,804,1419,1057,1458,1568,1557,1566,1569,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},1568,[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)}.`}},1569,[17,85,780,777,804,1568,1566,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}]},1570,[17,264,385,85,780,777,858,876,1571,915,1215,1465,804,1561,1057,1568,1572,1566,1569,1567,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)}))},1571,[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)},1572,[915]); +__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))})]})}},1573,[17,85,777,804,1574,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)},1574,[]); +__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:h,today:O,now:I,meId:N,me:X}=(0,A.useCtx)(3e4);(0,x.useTipsPosted)(e,O);const Z=(0,A.useSignedIn)();(0,m.useSoldOutLink)(!0,(Z?.name??X).replace(' (example)',''));const[q,J]=(0,s.useState)({kind:'tab',tab:'home'}),[Q,Y]=(0,s.useState)(''),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,A.ensureAttendance)(O,I),(0,D.ensureChat)(I)},[O]),globalThis.__ccNow=I.getTime();const te=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=V[t];return void J(e?{kind:'edit',id:e}:{kind:'page',id:t})}J('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:te}),()=>C.useVoiceNav.setState({go:null})),[te]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=te,globalThis.__deskGo=e=>J(e))},[te]),(0,v.useAlertWatcher)(e,{nag:'staff'!==h}),(0,w.useScheduledNotices)({rid:e,staffId:Z?.id??'',name:X,onOpen:e=>'bookings'===e?te('bookings'):'chat'===e?te('chat'):te('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==h&&!!Z});const ae=(0,s.useMemo)(()=>[...$,...F].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 ee.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=ae[Number(e.key)-1];return void(t&&(e.preventDefault(),J(t)))}if('z'===t&&!U(e.target)){const t=(0,z.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!U(e.target)){const t=(0,z.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae]);const se=B.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(h))&&!V[e.id]),ne=(0,s.useMemo)(()=>{const e=Q.trim().toLowerCase(),t={};return se.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[se,Q]),oe=$.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(h)),re=p.CAN.forecasts(h)?F:F.filter(e=>'rota'===e.s.id),ie='page'===q.kind?(0,B.pageFor)(q.id):void 0,le='tab'===q.kind?$.find(e=>K(e.s,q))?.label:'edit'===q.kind?F.find(e=>K(e.s,q))?.label:ie?.title,de='tab'===q.kind?$.find(e=>K(e.s,q))?.tip:'page'===q.kind?`${ie?.sub??''}. Press ${(0,_.CMD)()}K to jump to any page.`:'',ue=({label:e,s:t,n:a})=>{const s=K(t,q);return(0,W.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>J(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,W.jsx)(f.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,W.jsxs)(f.T,{size:11,colour:S.colours.muted,children:[(0,_.CMD)(),a]}):null]})},ce=({t:e})=>(0,W.jsx)(f.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),be='owner'===h?'OWNER':'manager'===h?'MANAGER':'STAFF';return(0,W.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,W.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,W.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,W.jsxs)(f.Row,{gap:10,children:[(0,W.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(u.VenueName,{name:c.name}),(0,W.jsx)(f.Row,{gap:6,children:(0,W.jsx)(l.AppBadge,{label:be})})]})]}),(0,W.jsx)(u.PoweredBy,{}),(0,W.jsx)(a.TextInput,{ref:ee,testID:"side-filter",value:Q,onChangeText:Y,placeholder:`Find a page (${(0,_.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[f.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,W.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Q?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{t:"Run the day"}),oe.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:t+1},e.label)),(0,W.jsx)(ce,{t:"Drag-and-drop editors"}),re.map((e,t)=>(0,W.jsx)(ue,{label:e.label,s:e.s,n:oe.length+t+1},e.label))]}),Object.entries(ne).map(([e,t])=>(0,W.jsxs)(r.default,{children:[(0,W.jsx)(ce,{t:e}),t.map(e=>(0,W.jsx)(ue,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,W.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,W.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,W.jsxs)(r.default,{style:{flex:1},children:[(0,W.jsx)(r.default,{testID:"desk-title",children:(0,W.jsx)(f.T,{size:24,weight:"bold",children:le??''})}),(0,W.jsxs)(f.Muted,{size:12,children:[Z?`Signed in as ${Z.name} \xb7 ${p.ROLE_LABEL[h]}`:`Preview \xb7 ${p.ROLE_LABEL[h]}`," \xb7 ",c.name]})]})}),(0,W.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[de?(0,W.jsx)(H.Tip,{children:de}):null,'edit'===q.kind?(0,W.jsx)(G,{id:q.id,rid:e,me:X,role:'owner'===h?'owner':'manager',today:O,venue:c.name}):(0,W.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===q.kind&&'home'===q.tab?(0,W.jsx)(L.Dashboard,{go:te}):null,'tab'===q.kind&&'orders'===q.tab?(0,W.jsx)(P.Orders,{}):null,'tab'===q.kind&&'bookings'===q.tab?(0,W.jsx)(E.Bookings,{}):null,'tab'===q.kind&&'forecast'===q.tab?(0,W.jsx)(R.Forecasts,{go:te}):null,'tab'===q.kind&&'chat'===q.tab?(0,W.jsx)(D.Chat,{go:te}):null,ie?(0,W.jsx)(ie.C,{go:te}):'page'===q.kind?(0,W.jsx)(f.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,W.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==h?(0,W.jsx)(g.PrintHost,{rid:e}):null,'staff'!==h?(0,W.jsx)(b.AlertHost,{variant:"managers",rid:e,me:X,onOpen:e=>te('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,W.jsx)(M.OnboardingHost,{go:te}),(0,W.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]),f=_r(d[12]),h=_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]);_r(d[33]);var O=_r(d[34]),_=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]);const $=[{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.'}],F=[{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:''}],V={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},K=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),U=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function G({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,h.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,W.jsx)(I.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,W.jsx)(N.RotaEditor,{today:o}):'brand'===e?(0,W.jsx)(O.BrandEditor,{rid:t}):(0,W.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,W.jsxs)(H.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,_.CMD)(),"Z undoes, then Save."]}),g?(0,W.jsx)(f.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,W.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,W.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{h.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)})]})}},1575,[813,812,17,385,278,85,19,1363,857,1366,1230,1394,777,998,876,891,1032,1481,1087,1086,1084,1489,1232,880,804,1419,1161,1057,1432,1483,1474,1485,1458,1487,1576,1555,1578,1580,1582,1579,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])},1576,[17,278,85,1502,857,777,876,814,1459,804,1577,1578,1579,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)})},1577,[]); +__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},1578,[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})},1579,[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."})]})]})}},1580,[812,17,85,777,860,816,891,893,894,845,867,1153,804,1577,1578,1579,1581,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])},1581,[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)}`},1582,[17,85,777,876,1060,804,1577,1578,1579,1051,1581,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]})}},1583,[13,17,856,1584,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)','')}})}},1584,[1459,1585,813,912,1072,1511,1209,1210,1028,1025,1026,1512,1546,1514,1153,891,978,1586,975,880,1031,1032,1495,914,1008,915,17,1155,1241,1245,1203,356,385,278,85,409,19,777,857,876,804,1161,1419,1066,1084,1086,1081,1027,1010,1057,1505,1500,1527,1587,1427,920,219,1246,1182,1188,1457,1202,1199,1482,1185,878,1212,1213,884,776,899,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']]},1585,[17,85,777,1057,899,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}},1586,[219,976]); +__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)','')},1587,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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]})}},1588,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1589,[1452,899,778,1413,1590,995,13,1617,479,17,368,319,219,24,85,805,857,1065,856,1619,19,858,998,876,804,1427,920,988,1620,1621,1028,1104,880,1008,914,1623,1383,8,1624,1625,1626,1627]); +__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])},1590,[1591,1614,1616]); +__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)}}},1591,[198,1592,1595,1609,1610,1611,1612,1613]); +__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}},1592,[198,1593]); +__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}},1593,[1594]); +__d(function(g,r,i,a,m,e,d){},1594,[]); +__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)}},1595,[1596,198,1592,1609,1610]); +__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]}})})},1596,[1597,1598,1608]); +__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()}})}},1597,[1598,1602,1607]); +__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}}},1598,[198,355,1599,1603,1604,1605,1606,1602,1607]); +__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}},1599,[198,1600,322,263,1601,1602]); +__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])},1600,[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}}},1601,[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},1602,[]); +__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}},1603,[]); +__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}},1604,[]); +__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])},1605,[1603]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1606,[]); +__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},1607,[355,1601]); +__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])},1608,[17,1598]); +__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}},1609,[1596,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])},1610,[1596,1609]); +__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}},1611,[1592]); +__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])},1612,[198,1592,1595,1593]); +__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})({})},1613,[]); +__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]))},1614,[198,37,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 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')},1615,[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]}},1616,[17,1591]); +__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]}})})},1617,[1618]); +__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(){}},1618,[]); +__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]})}},1619,[17,24,85,409,777,857,920,899,880,805,804,1560,1562,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()})},1620,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1621,[813,779,17,974,385,85,856,899,976,804,777,1352,971,880,1622,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1622,[17,1460,385,85,899,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1623,[]); +__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"},1624,[]); +__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"},1625,[]); +__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"},1626,[]); +__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"},1627,[]); +__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]})}},1628,[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},1629,[1630]); +__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},1630,[8,1631,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}))}}},1631,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1632,[]); +__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})}}},1633,[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 0112492e1f15a114708007dcb2e9e3ce2eda6938..886fe65839637cd7e92bae1b32f75c8e2e8c2dd0 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 1408d5d84f726176b8293f16decfb4c54348bf21..7297fe22164d35ce41416338a356f6770f4bbe21 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 961455dd33ded3fe1d545e9dc07fabc92916f967..c3216c0dcea14ff37136b031859edb2a574164cd 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-c2e88425bc"; +const V = "cc-desk-4ded1e9a3c"; 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=c2e88425bcf13aa1fd389d692d66294aa6a69c38ed6d26eb3a5091c3994476f5"]; +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=4ded1e9a3cbe57e4d364362420d9b6e0f35556825777b00027c9342056701f94"]; // 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 c82c29754fcad92519439b9e40a011fe40942cd9..8a136a84270664e77459182fdafae6ad603b1b86 100644 --- a/staff-app/_expo/static/js/web/bundle.js +++ b/staff-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,1500]); +__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,1502]); __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,1496,1499]); +__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,1498,1501]); __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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1236,1237,1242,1246,1248,1255,1309,1310,1311,1312,1313,1314,1316,1317,1318,1319,1323,1326,1327,1328,1329,1332,1406,1407,1408,1410,1451,1452,1495]); +__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/manage/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[30],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,1023,1237,1238,1243,1247,1249,1256,1310,1311,1312,1313,1314,1315,1317,1318,1319,1320,1324,1327,1328,1329,1330,1333,1408,1409,1410,1412,1453,1454,1497]); __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,909,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,[]); @@ -855,7 +855,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";Object.defineProperty(e,"__esModule",{value:!0})},772,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},773,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},774,[]); -__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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1143,1146,1147,1150,1168,1165,1169,1170,1173,1174,1175,1178,1181,1192,1195,1200,1202,1203,1028,884,920,1205,1156,1206,1218,1219,1228,1221,1154,1230,1234,1196,858,1152,899,1235,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.ChefApp=function({section:e}={}){const{r:s,rid:i,me:n,now:G}=(0,V.useChef)(3e4);(0,je.useReviewAlerts)(i);const _=(0,M.useSignedIn)(),J=_?.id??V.CHEF_ID,X=_?.ownerAccess&&'owner'!==_.role?'owner privileges':_?.managerAccess&&'staff'===_.role?'manager privileges':'',ve=(0,Te.useSync)(e=>e.perms),Ce=ve.includes('*')||ve.includes('takings.view');(0,o.useSoldOutLink)(!0,(_?.name??n).replace(' (example)',''));const Be=e?He[e]:void 0,[$e,Oe]=(0,A.useState)(Be?.tab??'home'),[Ee,Le]=(0,A.useState)(Be?.k??null),[Ne,We]=(0,A.useState)(Be?.stock??'levels'),[Fe,Ge]=(0,A.useState)(void 0),[Ke,Me]=(0,A.useState)(Be?.gp??'dishes'),Ve=(0,A.useRef)(null),ze=(0,y.ymd)(G),Ue=(0,y.ymd)(new Date(G.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const qe=(0,se.useTravelDay)('chef',ze),Qe='home'===$e&&!qe;(0,S.useKitchenTodoChime)(i,ze,()=>Ze('kitchen','bookings')),(0,ye.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,M.ensureAttendance)((new Date).toISOString().slice(0,10),G)},[]);const Ye=(0,A.useRef)({t:'home',k:null});Ye.current={t:$e,k:Ee};const Je=(0,A.useRef)([]),Xe=(0,r.useScrollMemory)(Ve),Ze=(0,A.useCallback)((e,t=null)=>{'takings'!==t||Ce||(t=null);const s=Ye.current;s.t===e&&s.k===t||(Je.current=[...Je.current,{...s,y:Xe.leave()}].slice(-30),Xe.restore(0)),Oe(e),Le(t)},[Ce]),et=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Ye.current;let t=Je.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Je.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Xe.leave(),Oe(s.t),Le(s.k),Xe.restore(s.y??0),!0},[]);(0,l.useWebBack)(et);const tt=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&We(s),'gp'===e&&s&&Me(s),Ze(e,t)})},[Ze]),(0,f.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,T.useScheduledNotices)({rid:i,staffId:_?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Ze('kitchen','orderlists'),'chat'===e&&Ze('kitchen','live')}}),(0,P.useOffRotaPrompt)({rid:i,staffId:_?.id??''}),(0,A.useEffect)(()=>{const e=B.default.addEventListener('hardwareBackPress',et);return()=>e.remove()},[et]),(0,A.useEffect)(()=>{'takings'!==Ee||Ce||(Le(null),Oe('kitchen'))},[Ee,Ce]),(0,Te.useSync)(e=>e.perms.join(','));const st=(0,H.kitchenHistoryAccess)(i),it=De.filter(e=>('takings'!==e.id||Ce)&&('bookinghistory'!==e.id||st)&&('kitchensetup'!==e.id||st)),at=Ee&&('takings'!==Ee||Ce)?De.find(e=>e.id===Ee):null,ot=((0,E.default)().width,at?at.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:pe.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Se.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:K.colours.bg},edges:['top','bottom'],children:[(0,Se.jsxs)(L.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:K.colours.border,gap:6},children:[(0,Se.jsxs)(L.default,{testID:"header-me-wrap",style:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',gap:8,minHeight:44,maxWidth:'100%'},children:[(0,Se.jsx)(L.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:K.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Se.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Se.jsx)(ce.StaffAvatar,{id:V.CHEF_ID,size:24,ring:!1}),(0,Se.jsxs)(L.default,{style:{flexShrink:1},children:[(0,Se.jsxs)(F.T,{size:13,weight:"semibold",colour:K.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Se.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})}),(0,b.openedFromDisplay)()?(0,Se.jsx)(b.BackToDisplayButton,{compact:!0}):null]}),(0,Se.jsx)(W.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,ue.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:K.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Se.jsx)(F.T,{size:13,colour:K.colours.gold,children:"Staff app \u203a"})})]}),(0,Se.jsxs)(O.default,{ref:Ve,...Xe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===$e?(0,Se.jsx)(de.AlertsBanner,{}):null,'home'===$e?(0,Se.jsx)(le.WhosOnShift,{}):null,(0,Se.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Ee||tt),onBack:et,title:ot}),'home'===$e?(0,Se.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&qe?(0,Se.jsx)(se.DayView,{rid:i,day:qe,today:ze,app:"chef"}):null,'home'===$e?(0,Se.jsx)(re.WhoBar,{}):null,Qe&&_?(0,Se.jsx)(h.MyTasksToday,{rid:i,staffId:_.id,name:_.name,onShift:(0,f.shiftNow)(_.id,G.getTime()).on}):null,Qe&&(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(x.CoversToday,{rid:i,onPress:()=>Ze('kitchen','bookings')}):null,Qe?(0,Se.jsx)(j.LastFoodBanner,{rid:i,now:G}):null,Qe?(0,Se.jsx)(w.NextTableFreeCard,{rid:i,now:G}):null,Qe?(0,Se.jsx)(v.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,Qe?(0,Se.jsxs)(L.default,{style:{gap:4},children:[(0,Se.jsx)(v.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Se.jsx)(v.PlattersBooked,{rid:i,date:Ue,label:"Platters booked tomorrow"})]}):null,Qe&&!(0,k.isKitchenViaDisplay)()?(0,Se.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&We(t),'gp'===e&&t&&Me(t),'orders'===e&&Ge(t),Ze(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Ne?'deliveries':'take'===Ne?'count':'deliveries'},`s-${Ne}`),'gp'!==$e||c.PITCH?null:(0,Se.jsx)(ee.KitchenCosts,{rid:i,me:(_?.name??n).replace(' (example)',''),actor:{name:(_?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Ke}`),'stock'===$e&&c.PITCH?(0,Se.jsx)(Z.StockScreen,{initial:Ne},Ne):null,'gp'===$e&&c.PITCH?(0,Se.jsx)(z.GpScreen,{initial:Ke},Ke):null,'creator'===$e?(0,Se.jsx)(pe.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Se.jsx)(Q.OrdersScreen,{focus:Fe},Fe??'all'):null,'rota'===$e?(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||at?null:(0,Se.jsxs)(L.default,{style:{gap:10},children:[(0,Se.jsxs)(L.default,{style:{borderRadius:14,borderWidth:1,borderColor:K.colours.border,backgroundColor:K.colours.surface,overflow:'hidden'},children:[Re.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Ze(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id)),it.map(e=>(0,Se.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Ze($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:K.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Se.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,Se.jsxs)(L.default,{style:{flex:1},children:[(0,Se.jsx)(F.T,{weight:"medium",children:e.title}),(0,Se.jsx)(F.Muted,{children:e.sub})]}),(0,Se.jsx)(F.T,{colour:K.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Se.jsx)(F.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Se.jsxs)(F.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Te.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Ee&&J?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Se.jsx)(oe.ClockInOut,{}),(0,Se.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Ee?(0,Se.jsxs)(L.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Se.jsx)(ie.MyPeriods,{staffId:J}),(0,Se.jsx)(te.MyHoursPay,{staffId:J}),(0,Se.jsx)(ae.MyTips,{staffId:J}),(0,Se.jsx)(F.Card,{children:(0,Se.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Ee?(0,Se.jsx)(L.default,{testID:"chef-alerts",children:(0,Se.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Ee?(0,Se.jsx)(t.AvatarMaker,{meId:_?.id??V.CHEF_ID,me:n}):null,'reviews'===Ee?(0,Se.jsx)(xe.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Ee?(0,Se.jsx)(R.BookingHistory,{rid:i,today:ze}):null,'bookings'===Ee?(0,Se.jsx)(I.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Ee?(0,Se.jsx)(ke.SpecialsEditor,{rid:i,me:n,app:"chef",now:G}):null,'forecast'===Ee?(0,Se.jsx)(U.ChefForecast,{openPrep:()=>Ze('kitchen','prep')}):null,'prep'===Ee?(0,Se.jsx)(q.PrepScreen,{}):null,'live'===Ee?(0,Se.jsx)(q.TeamScreen,{}):null,'waste'===Ee?(0,Se.jsx)(q.WasteScreen,{}):null,'recipes'===Ee?(0,Se.jsx)(me.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Ee?(0,Se.jsx)(q.AllergenScreen,{openCards:()=>Ze('kitchen','recipes')}):null,'takings'===Ee&&Ce?(0,Se.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Ee?(0,Se.jsx)(we.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Ee?(0,Se.jsx)(h.KitchenTeamTasks,{rid:i,actor:_}):null,'orderlists'===Ee?(0,Se.jsx)(C.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'kitchensetup'===Ee?st?(0,Se.jsx)(D.TempUnitsSetup,{}):(0,Se.jsx)(F.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Ee||'compliance'===Ee||'foodsafety'===Ee?(0,Se.jsx)(ge.HaccpLog,{mode:"chef",me:n,meId:V.CHEF_ID,now:G,rid:i}):null,'accidents'===Ee?(0,Se.jsx)(he.AccidentBook,{app:"chef",me:n,meId:V.CHEF_ID,now:G,seeAll:!1}):null]}),(0,Se.jsx)(Pe.BottomTabs,{tablist:!0,background:K.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Ze(e),tabs:Ie.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Se.jsx)(be.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Se.jsx)(fe.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),H=_r(_d[27]),A=_r(_d[28]),B=e(_r(_d[29]));_r(_d[30]);var $=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),L=e(_r(_d[34])),N=_r(_d[35]),W=_r(_d[36]),F=_r(_d[37]),G=_r(_d[38]),K=_r(_d[39]),M=_r(_d[40]),_=_r(_d[41]),V=_r(_d[42]),z=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),ae=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),be=_r(_d[67]),fe=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]),Se=_r(_d[78]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Ie=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:pe.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Re=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],De=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, probe checks, cleaning, training, House Rules, allergen matrix'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'haccp'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,V.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,V.useWeek)(),{covers:h,label:p,enough:k,booked:b}=(0,V.useForecast)(),f=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,V.isLow)(e.onHand,e.par)),x=f.filter(e=>e.ordersToday&&!e.placedToday),j=(0,_.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,ve.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Se.jsxs)(L.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Se.jsx)(ge.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Se.jsxs)(F.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Se.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,Se.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Se.jsx)(F.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Se.jsxs)(F.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,V.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Se.jsx)(V.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,V.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,V.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,G.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Se.jsx)(V.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,G.gbp)((0,V.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Se.jsx)(V.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Se.jsx)(V.Tile,{label:"Waste this week",value:t.waste.length?(0,G.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,V.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Se.jsx)(V.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Se.jsx)(V.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${b}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Se.jsx)(V.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Se.jsxs)(F.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),w.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Se.jsx)(F.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Se.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Se.jsxs)(F.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Se.jsx)(F.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[pe.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Se.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:K.colours.gold,backgroundColor:K.colours.surface},children:(0,Se.jsxs)(F.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Se.jsx)(F.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Se.jsx)(Ce.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},775,[776,890,869,891,898,1025,1026,978,880,1027,1031,1032,922,1065,1066,863,1072,1074,1075,1078,1081,1084,1086,1087,1088,1126,1128,1063,17,356,219,385,278,409,85,19,857,777,851,804,1057,1138,1144,1147,1148,1151,1169,1166,1170,1171,1174,1175,1176,1179,1182,1193,1196,1201,1203,1204,1028,884,920,1206,1157,1207,1219,1220,1229,1222,1155,1231,1235,1197,858,1153,899,1236,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.styliseOnDevice=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.jsx)(s.T,{size:14,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,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function v(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function b(e){const{img:t,url:a}=await f(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},776,[17,319,219,385,85,777,884,888,885,804,889,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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=v,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,R.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,R.jsx)(F,{}):null]});return(0,R.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,R.jsx)(v,{title:t,subtitle:r,back:o,right:l})}),c?(0,R.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,R.jsx)(p.default,{style:{flex:1},children:u}),s?(0,R.jsx)(p.default,{style:N.footer,children:(0,R.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=H,_e.Card=E,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,R.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:T?'center':'flex-start'}],children:(0,R.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=V,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return O}}),_e.Row=_,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return M}}),_e.Field=function({label:e,money:t,onChangeText:r,...l}){return(0,R.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,R.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t?{keyboardType:'decimal-pad',inputMode:'decimal'}:{},...l,onChangeText:t&&r?e=>r((0,B.sanitiseMoneyTyping)(e)):r,style:[N.input,l.multiline&&{minHeight:70,textAlignVertical:'top'},l.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,R.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,R.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,R.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,R.jsxs)(_,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,R.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,R.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,R.jsxs)(_,{gap:10,children:[(0,R.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,R.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,R.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,R.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,R.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y,centerTitle:w,onTypingDone:W,typingDoneLabel:k}){const{height:S}=(0,x.default)(),I=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},B=(0,r.useTyping)(),T=(0,r.useVisibleArea)(),P=B&&T&&T.height{W?W():(0,r.hideKeyboard)()},testID:"sheet-done",hitSlop:6,style:({pressed:e})=>({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,R.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,D?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,R.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,R.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,R.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,R.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,R.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]),R=_r(d[24]);const D=['kirkton','abbotsford'].includes(k.VENUE_RID),T='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(T&&('semibold'===l||'bold'===l)&&!j);return(0,R.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,R.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),A=e=>(0,R.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,R.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??T});function v({title:e,back:t=!0,right:r,subtitle:o}){return(0,R.jsxs)(p.default,{style:N.brandBar,children:[(0,R.jsxs)(p.default,{style:N.row,children:[(0,R.jsx)(p.default,{style:N.brandSide,children:t?(0,R.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,R.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,R.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,R.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,R.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,R.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,R.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,R.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function F(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,R.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,R.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function H({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,R.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,R.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,R.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function E({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,R.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,R.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function V({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,R.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,R.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,R.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,H.centreRow=!0;const $=({phone:e})=>(0,R.jsx)(V,{kind:"warn",title:"Allergies",children:"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. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),O=()=>(0,R.jsx)(V,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function _({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===E?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(T&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,R.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=T&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,R.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const M=()=>(0,R.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},777,[778,779,815,812,13,816,17,362,378,219,385,278,24,393,85,409,19,804,811,855,805,856,857,840,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},778,[]); @@ -1058,7 +1058,7 @@ __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";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{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()})},975,[17,976]); __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},976,[973,972,977]); __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'}},977,[973]); -__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.208'},978,[]); +__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.209'},978,[]); __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 d}}),e.executeMutation=async function(t){const n=(t,n)=>{throw Object.assign(t,{status:n})};if('rpc'===t.kind){const{error:r,status:s}=await l().rpc(t.fn,t.values??{});return r&&n(r,s),'ok'}const r=l().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:s,status:o}=await r.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(s&&'stock_events'===t.table&&'23503'===s.code&&/undoes/i.test(String(s.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const s=await r.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return s.error&&n(s.error,s.status),'ok'}return s&&await h(t,(0,c.resolveUniqueConflict)(t,s))||s&&n(s,o),'ok'}let s='update'===t.kind?r.update(t.values??{}):r.delete();for(const[n,r]of Object.entries(t.match??{}))s=s.eq(n,r);const{data:o,error:u,status:d}=await s.select();if(u&&await h(t,(0,c.resolveUniqueConflict)(t,u)))return'ok';u&&n(u,d);if('update'===t.kind&&(!o||0===o.length)){const n=(0,c.resolveMissingUpdate)(t);return'already-saved'===n.kind||'update-unversioned'===n.kind&&await h(t,n)?'ok':'conflict'}return'ok'};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),c=_r(_d[6]);const l=()=>(0,r.getSupabase)();class d{constructor(t,n={}){this.table=t,this.opts=n,this.keyOf=n.keyOf??(t=>String(t.id)),this.keyColumns=n.keyColumns??['id'],this.venueCol=n.venueColumn??'venue_id'}rows(t){return n.cache.rows(this.table,t)}get(t,r){return n.cache.get(this.table,t,r)}subscribe(t,r){return n.cache.subscribe(this.table,t,r)}hydrate(t){return n.cache.hydrate(this.table,t)}async refresh(r,s={}){const o=()=>{let t=l().from(this.table).select('*').eq(this.venueCol,r);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),s.filter&&(t=s.filter(t)),t},c='bookings'===this.table?await(0,t.readPages)(async(t,n)=>{const{data:r,error:s}=await o().order('id').range(t,n);if(s)throw s;return r??[]}):await(async()=>{const{data:t,error:n}=await o().limit(this.opts.limit??1e3);if(n)throw n;return t??[]})();return n.cache.replace(this.table,r,c.map(t=>[this.keyOf(t),t]),t=>u.mutationQueue.hasPending(this.table,r,t)),c}async create(t,r){const o={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,s.uuid)()}:{},...r,[this.venueCol]:t},c=this.keyOf(o);return n.cache.put(this.table,t,c,o),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:o,conflictKey:this.opts.conflictKey??'id'}),o}async update(t,r,s,o={}){const c=n.cache.get(this.table,t,r),l={...this.matchFor(r,c),...o,[this.venueCol]:t};n.cache.patch(this.table,t,r,{...s,updated_at:(new Date).toISOString()}),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:r,values:s,match:l})}async remove(t,r){const s=n.cache.get(this.table,t,r),o={...this.matchFor(r,s),[this.venueCol]:t};n.cache.remove(this.table,t,r),await u.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:r,match:o})}matchFor(t,n){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const r={};for(const t of this.keyColumns)r[t]=n?.[t];return r}}async function h(t,n){if('already-saved'===n.kind)return!0;if('unresolved'===n.kind)return!1;if('merge'===n.kind&&'name-ci'===n.lookup){const r=String(n.match.venue_id??t.venueId??'');if(!r)return!1;const{data:s,error:u}=await l().from(n.table).select('id,name,deleted_at').eq('venue_id',r).is('deleted_at',null);if(u||!s)return!1;const c=(0,o.findSavedPlanByName)(s,String(n.match.name??''));if(!c)return!1;return!(await l().from(n.table).update(n.patch).eq('id',c.id).is('deleted_at',null)).error}if('merge'===n.kind||'update-unversioned'===n.kind){let r=l().from('merge'===n.kind?n.table:t.table).update(n.patch);for(const[t,s]of Object.entries(n.match))r=r.eq(t,s);const s=await r.select();return!s.error&&!!s.data?.length}return!1}},979,[980,981,928,972,982,976,983]); __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())}}}},981,[972]); @@ -1222,365 +1222,367 @@ __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";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return r}}),_e.revenueHistory=function(e,t,r=28){const s=[];if(!(0,a.examplesAllowed)())return s;for(let a=r;a>=1;a--){const r=(0,o.addMins)(t,1440*-a),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=t=>.85+.3*n((0,o.ymd)(r)+t+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,o.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,a.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*n(e.id+'s')),o=.24+.22*n(e.id+'c'),a=e.price??0,r=Math.round(a*(1-o));return{item:e,sold:t,revenue:t*a,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return s}}),_e.crmCustomers=function(){return(0,a.examplesAllowed)()?i.map((e,t)=>{const o=n(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${d[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:r[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return u}}),_e.insights=function(e,n,r,s,i,d,u){const p=[];if(!(0,a.examplesAllowed)())return c(e,n,r,s,i,d,u);const h=new Date(d);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,t.forecastToday)(e,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,o.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,t.forecastToday)(e,n,r,s,d),v=l[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-d.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,o.venueYmd)(d)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]);const n=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},r=['Dine-in','Takeaway','Table QR'];const s={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],d=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const l=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}],u=()=>(0,a.examplesAllowed)()?l:[];function c(a,n,r,s,i,d,l){const u=[],c=(0,t.forecastToday)(a,n,r,s,d);c.enough||u.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:c.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const p=(0,o.ymd)(d),h=n.filter(e=>e.date===p&&'noshow'===e.status).length;h&&u.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${h} no-show${1===h?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const b=i.filter(e=>e.stars<=2).length;b&&u.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${b} low rating${1===b?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const m=s.filter(e=>e.date>=p).sort((e,t)=>e.date.localeCompare(t.date))[0];return m&&u.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${m.title}`,body:`${(0,o.niceDate)(new Date(m.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),u.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${l} covers so far today`,body:`Seated bookings and walk-ins recorded in CoverCharge today. ${(0,e.laterTodayLine)((0,e.laterTodayCovers)(n,p))}`}),u}},1139,[1055,1140,863,869]); __d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1140,[1053,861,1141,862,863,869,1142]); __d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1141,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863]); -__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1143,[890,17,820,385,85,858,876,1144,1140,777,804,1057,1138,1002,878,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,f.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,f.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,p.tillTakingsOf)(e.vals)})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),f=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1144,[17,85,777,858,1008,869,1145,816,839,1142,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1145,[17,869]); -__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1146,[17,385,85,777,851,804,1139,1138,1143,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1147,[17,385,85,777,858,1140,863,804,1148,1144,1143,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1148,[813,17,266,347,219,85,409,780,777,812,804,1149,8]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1149,[]); -__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1150,[812,896,1151,820,843,1152,1153,17,385,278,85,777,858,867,1154,876,909,845,851,1159,863,804,1160,1085,1057,1139,1138,1161,853,1143,1002,884,1162,920,899,1165,902,1071,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1151,[1138,896]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1152,[812,17,85,777,858,891,876,892,893,894,816,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1153,[]); -__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1154,[812,779,17,319,385,85,804,777,858,1155,1026,867,845,847,870,1082,1156,840,1157,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1155,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1156,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1157,[17,85,777,804,1158,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1158,[831,899,880]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1159,[863]); -__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1160,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1161,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1162,[887,813,17,378,219,385,85,884,777,885,876,1163,886,816,805,1164,899,804,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1163,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1164,[928,971,899,972]); -__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1165,[17,385,85,777,1166,876,902,1071,909,899,1060,1167,863,1097,1051,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1166,[17,85,777,1167,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1167,[]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1168,[1151,896,17,362,85,777,876,909,851,804,1057,1143,1002,1169,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1169,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1143,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1170,[896,856,17,898,1171,319,385,85,1172,777,897,895,1000,804,858,1055,863,1097,899,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1171,[219,811]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1172,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1173,[812,1000,1151,896,17,385,85,777,876,851,804,1143,1002,840,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1174,[]); -__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1175,[812,1176,17,385,85,409,777,876,851,863,804,1177,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1177,[17,385,85,777,804,805,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1178,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1179,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1179,[17,777,858,1180,8]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1180,[362]); -__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1181,[812,1033,1176,17,1182,219,385,409,85,1184,1185,1186,777,816,876,851,1034,804,889,1192,1177,1057,1035,1187,856,1188,1193,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1182,[17,385,85,1183,804,777,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1183,[17,780,8]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1184,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1185,[17,85,777,812,876,851,1184,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1186,[812,1184,17,385,85,777,884,876,1071,863,804,1177,1057,1187,856,1188,1185,1189,1191,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1187,[1033,1049,1064]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1188,[17,85,777,876,1008,1033,1064,1062,1187,804,856,1186,1050,1057,8]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1189,[1034,1190]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1190,[1034,1184]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1191,[17,85,777,812,1033,1034,1189,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1192,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1160,1177,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1193,[1033,17,385,85,777,812,876,1190,1034,1194,1097,804,1181,1057,1051,1184,1189,1035,8]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1194,[]); -__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.useWeekSales=te,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return ne}}),_e.rotaGrid=ae,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),B=(0,F.useDateCalendar)(),[P,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[W,E]=(0,r.useState)('week'),[Q,X]=(0,r.useState)(!1),ie=(0,O.useSignedIn)()?.name??'',re='staff'!==n,de=(0,D.addMins)(ee(t),7*j*1440);de.setHours(0,0,0,0);const ce=te(de),ue=ce.sales,he='none'===ce.mode,fe=Array.from({length:7},(e,t)=>{const s=new Date(de);return s.setDate(de.getDate()+t),(0,D.ymd)(s)}),me=(0,s.visibleShifts)(i,re).filter(e=>e.date>=fe[0]&&e.date<=fe[6]),ge=(()=>{const e=new Date(de);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),pe=me.filter(e=>!e.published||e.changed).length,xe=i.filter(e=>e.date>=ge&&e.date!!(0,s.leaveOn)(h,e,t),je=fe.map(e=>(0,p.workingShifts)(me,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(J(s=t)-Z(J(s)))*(d[s.staffId]??0);var s},0)),ye=je.reduce((e,t)=>e+t,0),we=ue.reduce((e,t)=>e+t,0),ke=(e,t)=>t?Math.round(e/t*100):0,Ie=re?l:l.filter(e=>e.id===a),Se=(0,o.useNarrow)(),Ce=Math.max(0,fe.indexOf((0,D.ymd)(t))),[De,ve]=(0,r.useState)(null),Te=De??Ce,$e=(e,t)=>!Se||t===Te,[Oe,Me]=(0,r.useState)(0),Be=ae(Oe,Se?1:7),Pe=Be.cell,Re=Be.name;return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Week",selected:'week'===W,onPress:()=>E('week')}),(0,K.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===W,onPress:()=>E('requests')}),(0,K.jsx)(m.Chip,{label:"Availability",selected:'availability'===W,onPress:()=>E('availability')})]}),'week'===W?(0,K.jsxs)(K.Fragment,{children:[!re&&a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,K.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,K.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,Y.timeSheetLabel)(fe[0],fe[6]),onPress:()=>{(0,Y.setHoursPreset)(fe[0],fe[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,K.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Oe?Math.min(Oe,Be.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,K.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,K.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(de)]}),(0,K.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",re?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,K.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,K.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:B.openCal,style:{minWidth:96}})}),(0,K.jsx)(F.AppDateCalendar,{visible:B.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(de),idPrefix:"rota-cal",onClose:B.closeCal,onDay:e=>{S((0,F.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),re?(0,K.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,K.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(xe?` (${xe})`:''),disabled:!xe,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ge,fe[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,K.jsx)(m.Button,{small:!0,kind:"success",label:pe?`Publish ${pe} ${1===pe?'change':'changes'}`:'Week published',disabled:!pe,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(fe[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),pe?(0,K.jsx)(m.Badge,{kind:"amber",label:`${pe} unpublished`}):me.length?(0,K.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,P?(0,K.jsx)(m.Banner,{kind:"success",title:P}):null,Se?(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>V.IS_CAR?(0,K.jsx)(m.Button,{kind:t===Te?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}${t===Te?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>ve(t),style:{minHeight:64,minWidth:96}},e):(0,K.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(fe[t]).getDate()}`,selected:t===Te,onPress:()=>ve(t)},e))}):null,(0,K.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Oe)>1&&Me(t)},style:{alignSelf:'stretch'},children:(0,K.jsx)(le,{fits:Se||Be.fits,children:(0,K.jsxs)(f.default,{testID:"rota-grid",style:{gap:ne,width:Be.width,alignSelf:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:ne,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},Se||Be.fits?oe:null],children:[(0,K.jsx)(f.default,{style:{width:Re,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,K.jsx)(f.default,{testID:"rota-date",style:{width:Pe,alignItems:'center'},children:(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,colour:fe[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(fe[s]).getDate()]})},e)).filter($e)]}),Ie.map(e=>(0,K.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:ne,alignItems:'center'},children:[(0,K.jsxs)(f.default,{testID:"rota-name",style:{width:Re,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,K.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,K.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(me,e.id,fe[n]),o=(c[e.id]??[]).includes(n),l=be(e.id,fe[n]),i=(0,x.rotaCellWorked)(a,b,e.id,fe[n],re),r=!(!re||!i.workedLine&&!i.onShiftNow);return(0,K.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,_.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!re,onPress:()=>{a?N({staffId:e.id,date:fe[n],shift:a}):z({staffId:e.id,date:fe[n]})},style:({pressed:e})=>({width:Pe,minHeight:V.IS_CAR?64:r?80:52,height:r||(0,_.cleanBadge)(a?.badge)||V.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,_.cleanBadge)(a?.badge)?6:0}),children:[a?(0,K.jsxs)(m.T,{size:Be.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':re?'Add':'\u2013'}),(0,_.cleanBadge)(a?.badge)?(0,K.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,K.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,_.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,K.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,K.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,K.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,fe[n])).toLowerCase()}):a&&o?(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!re||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,K.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter($e)]},e.id)),re?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne,marginTop:4},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour"})}),je.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:'example'===ce.mode?'Fcst sales (ex.)':'Fcst sales'})}),ue.map((e,t)=>(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter($e)]}),he?null:(0,K.jsxs)(f.default,{style:{flexDirection:'row',gap:ne},children:[(0,K.jsx)(f.default,{style:{width:Re},children:(0,K.jsx)(m.Muted,{children:"Labour %"})}),je.map((e,t)=>{const s=ke(e,ue[t]);return(0,K.jsx)(f.default,{style:{width:Pe,alignItems:'center'},children:(0,K.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:ue[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:ue[t]?`${s}%`:'\u2013'})},t)}).filter($e)]})]}):null]})})}),!re&&a?(0,K.jsx)(f.default,{testID:"rota-team-on",children:(0,K.jsx)(m.Card,{children:fe.map((e,t)=>(0,K.jsx)(y.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter($e)})}):null,re&&he?(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,K.jsx)(f.default,{testID:"labour-week-cost",children:(0,K.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,K.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ce.weeks?'1 week':`${ce.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ce.booked?(0,K.jsx)(f.default,{testID:"labour-booked",children:(0,K.jsxs)(m.T,{children:["Booked so far: ",ce.booked," Covers this week"]})}):null]})}):null,re&&!he?(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,K.jsxs)(m.Row,{gap:6,children:['example'===ce.mode?(0,K.jsx)(H.ExampleBadge,{}):null,(0,K.jsx)(m.Badge,{kind:ke(ye,we)>30?'red':'ok',label:`${ke(ye,we)}% this week`})]})]}),(0,K.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,C.gbp)(we)," forecast sales. Target 25\u201330%. ",'example'===ce.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=ke(je[5],ue[5]);return e&&e<24?(0,K.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,re?(0,K.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>re||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,K.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>G(n,e)).map(t=>(0,K.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,K.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!G(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),re?null:(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,K.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,K.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,w.isAnchorageVenue)(k.VENUE_RID)?w.ANCHORAGE_SWAP_NOTE:U(l.find(e=>e.id===a))?w.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),me.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,K.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,_.cleanBadge)(e.badge)?` \xb7 ${(0,_.cleanBadge)(e.badge)}`:'']}),t?(0,K.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>G(l.find(e=>e.id===a),e)).map(t=>(0,K.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),me.some(e=>e.staffId===a)?null:(0,K.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,K.jsx)(T.SectionHead,{title:"Holiday & time off"}),re?(0,K.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>X(!0)}):a?(0,K.jsx)(I.RequestTimeOff,{meId:a,me:ie,testID:"rota-requests-time-off"}):null,h.filter(e=>re||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,K.jsx)(m.Card,{children:(0,K.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,K.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,K.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&re?(0,K.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),re&&a?(0,K.jsx)(I.TimeOffSheet,{visible:Q,onClose:()=>X(!1),meId:a,me:ie,manager:!0}):null]}):null,'availability'===W?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",re?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ie.filter(e=>'owner'!==e.role||!re).map(e=>(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{gap:8,children:[(0,K.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,K.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,K.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,K.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,K.jsx)(q.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,_.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,K.jsx)(se,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,B.useClockArea)(e=>e.areas[x]),(0,B.areaOf)(x));const y=(0,P.privateClockVenue)(x),[w,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[V,U]=(0,r.useState)(null),[G,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,de=ne?(0,O.paidMins)({in:ne.in},e).worked:0,ce=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??V?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(U(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&U(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,K.jsx)(M.StaffAvatar,{id:h,size:48}),(0,K.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,K.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,K.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,K.jsx)(f.default,{testID:"clock-area-line",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.muted,children:ce?y?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,K.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,K.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(de)}):null,ne&&ae?(0,K.jsx)(f.default,{testID:"on-break",children:(0,K.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,K.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,K.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,K.jsxs)(K.Fragment,{children:[ae?(0,K.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,K.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,K.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,K.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):y?k(!0):xe('in')}}),fe?(0,K.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,K.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,K.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,K.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,K.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,K.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,K.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,K.jsx)(f.default,{testID:"clock-message",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,K.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,K.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,K.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,K.jsx)(f.default,{testID:"clock-area-warning",children:(0,K.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,K.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,K.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),G?(0,K.jsx)(re,{onClose:()=>Q(!1)}):null,(0,K.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),V?(()=>{const t=(0,O.paidMins)(V,e);return(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(V.out))]}),(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,K.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(V.in))," \xb7 out ",(0,D.hm)(new Date(V.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",V.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,K.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,K.jsx)(m.Sheet,{visible:w||I,onClose:()=>{k(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,K.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,K.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;k(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,K.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{k(!1),S(!1)}})]})}),le?(0,K.jsx)(ie,{rid:x,today:t,now:e}):null,(0,K.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,K.jsxs)(f.default,{style:{gap:12},children:[(0,K.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,K.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,K.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),y?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,K.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,K.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,K.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,K.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,K.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=de,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,K.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),de>360?(0,K.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,K.jsx)(m.Muted,{children:y?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,K.jsx)(f.default,{style:{gap:10},children:(0,K.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,K.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,K.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,K.jsxs)(K.Fragment,{children:[" ",(0,K.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,K.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,K.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,K.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,K.jsx)(ce,{now:e,today:t,meId:n}):(0,K.jsx)(de,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),y=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),B=_r(_d[32]),P=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),V=_r(_d[46]),K=_r(_d[47]);const U=e=>(0,w.deptKey)(e?.dept),G=(e,t)=>(0,w.canSwapWith)(e,t,k.VENUE_RID),Q=2650,X=1900,J=e=>e.end-e.start,Z=e=>e>8?.5:e>6?.3333333333333333:0,ee=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function te(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,D.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),r=(0,N.clampWeeks)(s.settings.forecastMinWeeks);return i?i.salesEnough?{mode:'real',weeks:r,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?i.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:r,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:r,booked:n,sales:t.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*Q+t.restOfDay.takeaway*X:0})}},[s,a,o,l,i,(0,D.ymd)(e)])}function se({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,_.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,K.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,E.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,K.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,K.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,K.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),_.ROLE_BADGES.map(e=>(0,K.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,K.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{children:"Start"}),(0,K.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:E.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:"End"}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:E.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,K.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,K.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",Z(l-a)?`, ${Math.round(60*Z(l-a))}m planned break`:'']}),(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,K.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,K.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,K.jsxs)(m.Row,{gap:6,children:[(0,K.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,K.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,K.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,K.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,_.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,_.cleanBadge)(u)?{badge:(0,_.cleanBadge)(u)}:{}}),t()}}),(0,K.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,K.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const ne=6;function ae(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*ne:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+ne),big:o>=104,fits:!e||s+t*(o+ne)<=e}}const oe={position:'sticky',top:0};function le({fits:e,children:t}){return e?(0,K.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,K.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function ie({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,K.jsxs)(m.Card,{children:[(0,K.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,K.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,K.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,K.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function re({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,y]=(0,r.useState)(h?Math.round(60*h.end):1200),[w,k]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,B=(e,t)=>(0,K.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,K.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,K.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,K.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,K.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,K.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,K.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,K.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,K.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,K.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,K.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,K.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),B(x,p)]}):null,$?(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),B(y,j)]}):null,M?(0,K.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,K.jsx)(m.Field,{label:"Note for your manager (optional)",value:w,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,K.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:w.trim(),at:t.toISOString()}),S(!0)}})]})}function de(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(ee(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),y=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,K.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,K.jsxs)(f.default,{children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,K.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,K.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,K.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,K.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,K.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),y.length?(0,K.jsx)(T.SectionHead,{title:"My correction requests"}):null,y.map(e=>(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,K.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,K.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,K.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,K.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsxs)(f.default,{style:{flex:1},children:[(0,K.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,K.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,K.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,K.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,K.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,K.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,K.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,K.jsx)(re,{onClose:()=>d(!1)}):null]})}function ce({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[y,w]=(0,r.useState)(null),[k,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),B=!!(0,O.useSignedIn)(),P=S?(0,Y.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>P.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),F=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),E=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&B?'No tax deducted':''}`}));return(0,K.jsxs)(f.default,{style:{gap:10},children:[(0,K.jsx)(W.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,K.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:P.map(e=>(0,K.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,Y.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,Y.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,K.jsxs)(m.Card,{children:[(0,K.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,K.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,Y.weekTitle)(x,n):'Last 7 days'}),(0,K.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,K.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,K.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(F))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,K.jsx)(o.WideTable,{children:(0,K.jsxs)(f.default,{style:{gap:2},children:[(0,K.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,K.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,K.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,K.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,K.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,K.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,K.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,K.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,K.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,K.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,K.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>w(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,K.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,K.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,K.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,K.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,K.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,K.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,K.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,K.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,K.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,K.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,K.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,K.jsx)(m.Muted,{children:"No manual changes yet."}),y?(0,K.jsx)(b.OverrideSheet,{a:y,staffId:y.staffId,date:y.date,onClose:()=>w(null)}):null,(0,K.jsxs)(m.Sheet,{visible:k,onClose:()=>I(!1),title:"Payroll export",children:[(0,K.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,K.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[E.slice(0,14).map((e,t)=>(0,K.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),E.length>14?(0,K.jsxs)(m.Muted,{children:["\u2026 ",E.length-14," more rows"]}):null]}),(0,K.jsxs)(m.Muted,{children:[E.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1195,[813,876,1196,1070,1176,923,924,17,975,976,219,385,278,85,777,858,1071,1197,1186,1162,1198,1059,805,1199,1140,851,863,804,1177,1160,1057,884,1012,912,913,1067,916,1069,1144,1142,1189,1191,1051,1060,1167,1166,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1196,[812,17,385,85,777,804,876,816,860,923,924,8]); -__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1197,[1060]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1198,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1199,[17,385,85,777,876,863,804,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1200,[17,85,777,876,804,1057,1060,1198,1071,1201,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1201,[863]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1202,[17,85,1057,804,777,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1203,[17,219,85,1057,876,1204,804,777,8]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1204,[]); -__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1205,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1206,[812,1207,779,1208,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1209,1212,1215,1217,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1207,[880,805,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1208,[17,1003,876,820]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1209,[219,1210]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1210,[1211,856]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1211,[928,903]); -__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1212,[813,1207,1033,779,812,1208,820,876,17,319,385,85,780,777,884,1003,1004,1213,804,889,1209,1214,8]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1213,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1214,[816,876,805]); -__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1215,[17,1033,362,219,85,777,876,1003,1214,1004,1216,804,889,1208,928,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1216,[1004,991]); -__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1217,[17,85,777,804,889,992,905,858,876,1033,1216,990,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1218,[]); -__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1219,[843,1028,17,219,385,85,780,858,804,777,1220,1104,1221,8]); -__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1220,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1221,[1222,1223,1225,1224,1226,1018,1227]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1222,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1223,[824,805,831,834,856,1018,1224]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1224,[843,219,856,1222]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1225,[17,858,845,853,851,1223,1222]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1226,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1227,[17,1223,899,928]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1228,[17,385,85,409,858,845,804,777,1219,1104,1229,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1229,[17,85,409,858,845,1221,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1230,[17,219,385,85,864,777,804,916,1231,1232,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1231,[856,806,928,971,916,1221,1232]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1232,[824,1233,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1233,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1234,[17,856,1231]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1235,[17,385,329,85,409,804,1183,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1236,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1237,[843,1099,861,13,17,1238,917,85,841,1239,1079,1055,777,845,851,1105,863,858,899,804,1180,848,995,998,1076,1107,1240,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1238,[812,17,219,85,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1239,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1240,[17,385,85,862,863,1033,1241,804,777,779,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1241,[1033]); -__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1242,[900,13,17,319,85,1243,1245,777,845,851,858,867,804,8]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1243,[901,17,1244,85,845,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1244,[880,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1245,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1246,[13,17,777,1247,858,1230,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1247,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1248,[822,13,17,1249,777,851,858,804,1250,1254,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1249,[17,368,85,858,851,804,777,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1250,[17,85,777,851,1251,1252,1253,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1251,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1252,[840]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1253,[928,899,1252]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1254,[831,928,971,899,880,1251]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1255,[1256,1257,805,1258,1267,1268,1269,843,13,17,219,385,85,1243,1245,777,845,851,862,858,900,804,1270,1230,856,876,1271,910,911,920,1273,1254,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1256,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1257,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1258,[17,85,777,1259,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1259,[806,1033,1260,1262,1264,17,85,812,777,804,1261,1265,1266,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1261,[]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1262,[1263,1261]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1263,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1264,[1261]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1265,[806,928]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1266,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1267,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return s}}),e.buildHistory=function(s,c,d,u,f,y=o){const l=(0,t.ymd)(f),b=(0,t.ymd)(new Date(f.getTime()-48384e5)),h=t=>t>=b&&tt.rid===s&&h(t.date));for(const t of k)w.add(t.date);const p=[...w].sort(),j=p.length?a(p[0],l):0,O=j>=7*y&&p.length>=2*y,N=t=>{const n={},o={};for(const t of p){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},_=(0,n.takingsRowsForForecast)(s,u,l,b),E=(0,n.forecastTakingsByDay)(_,l,b),F=_,M=(F.length?a(F.map(t=>t.date).sort()[0],l):0)>=7*y&&F.length>=2*y;return{covers:N(D),takeaway:N(T),days:p.length,spanDays:j,enough:O,minWeeks:y,takingsByDay:E,cashUps:F.length,salesEnough:M}};var t=r(_d[0]),n=r(_d[1]);const o=2,s=t=>{const n=Math.round(Number(t));return Number.isFinite(n)&&n>=1&&n<=8?n:o},a=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1142,[863,1143]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FORECAST_WINDOW_DAYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FORECAST_HALF_LIFE_DAYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"OUTLIER_MIN_N",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"OUTLIER_MEDIAN_MULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROTA_DAYS3",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dayDiff",{enumerable:!0,get:function(){return i}}),e.latestCashUpPerDate=p,e.median=m,Object.defineProperty(e,"recencyWeight",{enumerable:!0,get:function(){return h}}),e.forecastTakingsByDay=k,e.takingsRowsForForecast=function(t,n,r,a){return p(n.filter(n=>n.rid===t&&l(n)&&'number'==typeof n.takings&&n.takings>0&&n.date>=a&&n.date({date:t.date,pence:Math.round(100*t.takings)}))},e.confirmedTakingsPence=y,e.salesEnoughFromRows=b,e.kitchenOpenOn=w,e.salesMixWords=T,e.mondayYmd=D,e.weekSalesForRota=function(t){const n=D(t.mon),r=Array.from({length:7},(t,r)=>f(n,r)),a=t.bookings.filter(t=>!t.walkIn&&'confirmed'===t.status&&r.includes(t.date)).reduce((t,n)=>t+n.partySize,0),o=t.minWeeks;if(t.exampleSales){const n=r.map((n,r)=>{const a=w(t.kitchenHours,n),o=t.exampleSales[r]??0;return{date:n,pence:a?o:0,kind:a?o?'forecast':'none':'shut'}});return{sales:n.map(t=>t.pence),days:n,mode:'example',weeks:o,booked:a,weekPence:n.reduce((t,n)=>t+n.pence,0),mixWords:T(n)}}const s=d(t.now),c=d(new Date(t.now.getTime()-48384e5)),i=y(t.rid,t.cashUps),l=i.filter(t=>t.date>=c&&t.date[t.date,t.pence])),S=r.map(n=>{if(!w(t.kitchenHours,n))return{date:n,pence:0,kind:'shut'};const r=h.get(n);if(null!=r)return{date:n,pence:r,kind:'actual'};if(p){const t=m[u(n)];return{date:n,pence:t??0,kind:t?'forecast':'none'}}return{date:n,pence:0,kind:'none'}}),A=S.some(t=>'actual'===t.kind),O=S.some(t=>'forecast'===t.kind),M=A||O||p?'real':'none',x=S.reduce((t,n)=>t+n.pence,0);return{sales:S.map(t=>t.pence),days:S,mode:M,weeks:o,booked:a,weekPence:x,mixWords:T(S)}},e.weekSalesCardCopy=function(t){if('example'===t.mode)return{title:'Labour vs forecast sales',bodyTail:'Example figures: forecast sales use an example spend per cover.'};const n=t.days.some(t=>'actual'===t.kind),r=t.days.some(t=>'forecast'===t.kind),a=r&&!n?'Labour vs forecast sales':'Labour vs sales',o='Forecast sales are your average takings for each weekday from your cash-ups, with recent weeks counting for more.';return n&&r?{title:a,bodyTail:`${o} Cashed-up days use the real figures.`}:n&&!r?{title:a,bodyTail:'Sales are from your cash-ups (card + cash \u2212 card tips).'}:{title:a,bodyTail:o}};var t=_r(_d[0]);const n=56,r=14,a=3,o=2.5,s=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],c=t=>new Date(t+'T12:00:00'),i=(t,n)=>Math.round((c(n).getTime()-c(t).getTime())/864e5),u=t=>c(t).getDay(),d=t=>{const n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate();return`${n}-${String(r).padStart(2,'0')}-${String(a).padStart(2,'0')}`},f=(t,n)=>{const r=c(t);return r.setDate(r.getDate()+n),d(r)},l=t=>void 0===t.confirmedAt||!(!t.confirmedAt||!String(t.confirmedAt).length);function p(t){const n=new Map;for(const r of t){const t=n.get(r.date);(!t||(r.confirmedAt??'')>(t.confirmedAt??''))&&n.set(r.date,r)}return[...n.values()].sort((t,n)=>t.date.localeCompare(n.date))}function m(t){const n=[...t].sort((t,n)=>t-n);if(!n.length)return 0;const r=Math.floor(n.length/2);return n.length%2?n[r]:(n[r-1]+n[r])/2}const h=(t,n,a=r)=>Math.pow(.5,Math.max(0,i(t,n))/a);function k(t,n,r){const s=Array.from({length:7},()=>[]);for(const a of t)!(a.date=n)&&a.pence>0&&s[u(a.date)].push(a);return s.map(t=>{if(!t.length)return null;const r=m(t.map(t=>t.pence)),s=t.length>=a?t.filter(t=>t.pence<=o*r):t,c=s.length?s:t;let i=0,u=0;for(const t of c){const r=h(t.date,n);i+=r,u+=r*t.pence}return i>0?Math.round(u/i):null})}function y(n,r){const a=[];for(const o of r){if(o.rid!==n||!l(o))continue;const r=(0,t.dayTakingsOf)(o);null==r||r<=0||a.push({date:o.date,pence:Math.round(100*r),confirmedAt:o.confirmedAt})}return p(a)}function b(t,n,r){if(!t.length)return!1;const a=[...t].map(t=>t.date).sort()[0];return i(a,n)>=7*r&&t.length>=2*r}function w(t,n){const r=t?.[u(n)];return!!r}function T(t){const n=[];t.forEach((t,r)=>{if('actual'!==t.kind&&'forecast'!==t.kind)return;const a=n[n.length-1];a&&a.kind===t.kind&&a.idxs[a.idxs.length-1]===r-1?a.idxs.push(r):n.push({kind:t.kind,idxs:[r]})});return n.map(t=>{return`${n=t.idxs,1===n.length?s[n[0]]:`${s[n[0]]}\u2013${s[n[n.length-1]]}`} ${t.kind}`;var n}).join(', ')}function D(t){const n=new Date(t);n.setHours(0,0,0,0);const r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),d(n)}},1143,[839]); +__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,"CHEF_ID",{enumerable:!0,get:function(){return x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1144,[890,17,820,385,85,858,876,1145,1140,777,804,1057,1138,1002,878,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),k=(0,u.useCashUp)(e=>e.cashUps),y=(0,p.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,p.buildHistory)(e,n,l,k.map(e=>({rid:e.rid,date:e.date,takings:(0,f.tillTakingsOf)(e.vals),confirmedAt:e.confirmedAt??null})),t,y),[o,e,n,l,k,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),f=_r(d[8]),p=_r(d[9]),k=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1145,[17,85,777,858,1008,869,1146,816,839,1142,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1146,[17,869]); +__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.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:o}=(0,c.useChef)(),d=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(w,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const o='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+o))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1147,[17,385,85,777,851,804,1139,1138,1144,1002,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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1148,[17,385,85,777,858,1140,863,804,1149,1145,1144,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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1149,[813,17,266,347,219,85,409,780,777,812,804,1150,8]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CHART_PAD_L",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CHART_PAD_R",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=s,e.busiestText=c,e.peakOccupancyText=function(t,n){const o=String(new Date(t).getHours()).padStart(2,'0');return`Peak ${n} ${1===n?'cover':'covers'} at ${o}:00`},e.seatedNowText=function(t){return`Seated now ${t} ${1===t?'Cover':'Covers'}`},e.seatedNowCovers=function(t,n){return t.filter(t=>'seated'===t.status&&t.date===n).reduce((t,n)=>t+(Number(n.partySize)||0),0)},e.hourAxis=h,e.dayLabelWidth=x,e.daysAxis=function(n,o,u=1){if(!o.length||n<=0)return[];const a=Math.max(10,n-28-8),i=Math.max(1,o.length-1),s=t=>o.length<=1?28+a/2:28+t/i*a,c=t=>t.every((o,u)=>o.x>=0&&o.x+o.w<=n&&(0===u||t[u-1].x+t[u-1].w+2<=o.x)),h=(a,i)=>{const h=o.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%a===0).map(({t:o,i:a})=>{const c=o.length>i?o.slice(0,i):o,h=Math.min(n,x(c,u));return{x:Math.max(0,Math.min(n-h,s(a)-h/2)),y:0,w:h,h:t,text:c}});return c(h)?h.map((t,o)=>{const u=0===o?0:(h[o-1].x+h[o-1].w+t.x)/2+1,a=o===h.length-1?n:(t.x+t.w+h[o+1].x)/2-1,i=Math.max(0,t.x-u),s=Math.max(0,a-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+s,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-i,w:t.w+i,align:'right'};const c=Math.min(i,s);return{...t,x:t.x-c,w:t.w+2*c,align:'center'}}):null};for(let t=1;t<=o.length;t++){const n=h(t,3);if(n)return n;if(t>1){const n=h(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),s=o,f=u,l=Math.max(10,i-s-f),x=Math.max(1,n.t1-n.t0),b=h(i,n.t0,n.t1,n.hours).map(o=>({...o,y:Math.max(0,n.height-t)}));let p=null;if(n.busiest&&(n.busiest.covers>0||n.busiest.text)){const t=n.busiest.text??c(n.busiest.t,n.busiest.covers),o=Math.min(i,a(t,13)),u=(M=n.busiest.t,s+(M-n.t0)/x*l-o/2);p={x:Math.max(0,Math.min(i-o,u)),y:1,w:o,h:16,text:t}}var M;return{hours:b,busiest:p}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours},e.yTicks=function(t){const n=1.15*Math.max(8,t),o=[1,2,5,10,15,20,25,50,100];let u=5;for(const t of o){const o=Math.floor(n/t)*t,a=Math.round(o/t)+1;if(a>=2&&a<=3){u=t;break}}const a=[];for(let t=0;t<=n+1e-9;t+=u)a.push(Math.round(t));0!==a[0]&&a.unshift(0);return[...new Set(a)]},e.nowLineVisible=function(t){if(t.closed||t.past||!0!==t.live)return!1;const n=t.now.getTime(),o=t.open.getTime(),u=t.close.getTime();return n>=o&&n<=u},e.splitCurve=function(t,n){const o=[],u=[];let a=null;for(let i=0;in&&u.push(s),c&&s.tn){const t=(n-s.t)/(c.t-s.t);a={t:n,covers:s.covers+t*(c.covers-s.covers)}}}a&&(o.length&&o[o.length-1].t===a.t||o.push(a),u.length&&u[0].t===a.t||u.unshift(a));return{before:o,after:u}},Object.defineProperty(e,"YTICK_MIN_PLOT",{enumerable:!0,get:function(){return b}}),e.fitYTicks=function(t,n,o,u=13){const a=Math.max(26,Math.ceil(1.5*Math.max(u,13))+6);if(!t.length||ot.topo-4||h.push(c))}return h.sort((t,n)=>t.value-n.value)};const t=22,n=12,o=44,u=8,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.xl+(t-c)/p*b,w=f.map(o=>{const u=String(new Date(o).getHours()).padStart(2,'0'),i=a(u,n);return{x:M(o)-i/2,y:0,w:i,h:t,text:u}});for(let t=1;t<=Math.max(1,w.length);t++){const n=w.filter((n,o)=>o%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!s(n))return n}return[]}const f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',l=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function x(t,o=1,u=n){const a=[...t].reduce((t,n)=>{const o=f.indexOf(n);return t+(o<0?1e3:l[o])},0)/1e3;return Math.ceil(a*u*Math.max(1,o))+4}const b=72},1150,[]); +__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.PrepScreen=function(){const{k:e,menu:t,me:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.filter(e=>['a-fishsupper','a-mini-fish-goujons','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],F=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],G=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1151,[812,896,1152,820,843,1153,1154,17,385,278,85,777,858,867,1155,876,909,845,851,1160,863,804,1161,1085,1057,1139,1138,1162,853,1144,1002,884,1163,920,899,1166,902,1071,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1152,[1138,896]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};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]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1153,[812,17,85,777,858,891,876,892,893,894,816,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1154,[]); +__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,"fmtDate",{enumerable:!0,get:function(){return I}}),_e.SignOffLine=T,_e.CardView=B,_e.CardEditor=O,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,y]=(0,n.useState)([]),[j,I]=(0,n.useState)('free-from'),[w,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),P='edit'===l&&(0,m.canEditCards)(s.role),v=P?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===w?v:v.filter(e=>(0,m.cardState)(e)===w);return(0,m.filterCards)(e,p,b,j).slice().sort((e,t)=>e.section.localeCompare(t.section)||E(e.dish).localeCompare(E(t.dish)))},[v,p,b,j,w]),R=u.filter(e=>!e.signOff).length,M=D?u.find(e=>e.id===D):void 0,A=k&&'new'!==k?u.find(e=>e.id===k)??null:null,N=e=>y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,C.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,C.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,C.jsx)(d.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,P?(0,C.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,C.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,C.jsx)(d.Chip,{label:"Free from",selected:'free-from'===j,onPress:()=>I('free-from')}),(0,C.jsx)(d.Chip,{label:"Contains",selected:'contains'===j,onPress:()=>I('contains')}),b.length?(0,C.jsx)(d.Chip,{label:"Clear",onPress:()=>y([])}):null]}),(0,C.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,C.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>N(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,C.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),P?(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===w,onPress:()=>$('all')}),(0,C.jsx)(d.Chip,{label:`Awaiting sign-off (${R})`,selected:'awaiting'===w,onPress:()=>$('awaiting')}),(0,C.jsx)(d.Chip,{label:`Signed off (${u.length-R})`,selected:'signed-off'===w,onPress:()=>$('signed-off')})]}):null,(0,C.jsx)(r.default,{testID:"card-count",children:(0,C.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===j?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===j?' and ':' or ')}`:'']})}),L.map(e=>(0,C.jsx)(z,{c:e,actor:s,mode:l,editable:P,onPress:()=>T(e.id)},e.id)),L.length?null:(0,C.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,C.jsx)(d.Sheet,{visible:!!M&&!k,onClose:()=>T(null),title:M?.dish??'',maxWidth:640,testID:"card-sheet",children:M?(0,C.jsx)(B,{card:M,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:P?()=>S(M.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${A?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,C.jsx)(O,{rid:e,card:A,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=A,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=A(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[y,j]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const I=x?c.find(e=>e.id===x):void 0,w=y?c.find(e=>e.id===y)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,C.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,C.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,C.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,C.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,C.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,C.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,C.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,C.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,C.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,C.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,C.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,C.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,C.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,C.jsx)(d.Sheet,{visible:!!I&&!y,onClose:()=>b(null),title:I?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:I?(0,C.jsx)(B,{card:I,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>j(I.id):void 0}):null}),(0,C.jsx)(d.Sheet,{visible:!!y,onClose:()=>j(null),title:`Edit: ${w?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:y&&w?(0,C.jsx)(O,{rid:e,card:w,actor:t,onDone:e=>{j(null),b(e)}},y):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),C=_r(_d[19]);const I=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},w=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,$=e=>null==e?'Price on the board':w(e),D={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function T({card:e,testID:t}){return e.signOff?(0,C.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,C.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",I(e.signOff.at)]})}):(0,C.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,C.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function k({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,C.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,C.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function S({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,C.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,C.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const P=({label:e,gold:t,testID:s})=>(0,C.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),v=({title:e})=>(0,C.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,C.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,C.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function B({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=D[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,C.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,C.jsx)(k,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,C.jsx)(k,{dish:e.dish,height:180,radius:18}),f.length>1?(0,C.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,C.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,C.jsx)(k,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,C.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,C.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,C.jsx)(P,{label:e.section,gold:!0}),(0,C.jsx)(P,{label:$(e.price)}),x&&x.summary.lines.length?(0,C.jsx)(P,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,C.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,C.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,C.jsx)(T,{card:e,testID:"card-status"})}),'example'!==e.origin?(0,C.jsx)(j.TakeawaySwitch,{itemId:e.menuItemId,dish:e.dish,role:t.role,me:t.name,signedOff:!!e.signOff,priced:null!=e.price&&e.price>0}):null,(0,C.jsx)(v,{title:"Allergens"}),(0,C.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,C.jsx)(S,{map:e.allergens})}),e.allergenNotes?(0,C.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,C.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",I(e.allergensConfirmed.at),"."]}):null,(0,C.jsx)(v,{title:"Ingredients"}),e.ingredients.length?(0,C.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${w(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,C.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,C.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,C.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,C.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:w(n.cost)}):null]})]},e.id)})}):(0,C.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,C.jsx)(v,{title:"Method"}),e.steps.length?(0,C.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,C.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,C.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,C.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,C.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,C.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,C.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",I(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,C.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,C.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,C.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,C.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,C.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,C.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const L=()=>`i-${Math.random().toString(36).slice(2,9)}`,R=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:L(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},M=e=>{if(!e.trim())return null;const t=(0,y.parseMoneyInput)(e);return null!=t&&t>=0?Math.round(100*t):'bad'};function O({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[y,j]=(0,n.useState)(()=>R(l,b[0]??'Mains',c.name)),[I,w]=(0,n.useState)(null),[$,D]=(0,n.useState)(null),[T,S]=(0,n.useState)(!1),P=e=>j(t=>({...t,...e})),v=y.ingredients.filter(e=>e.name.trim()),B={ingredients:v,allergens:y.allergens,dismissed:y.dismissed},O=(0,m.suggestAllergens)(v),E=(0,m.unresolved)(B),A=e=>{const t=y.allergens[e],s={...y.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:y.dismissed.filter(t=>t!==e),confirm:!1})},z=e=>{const t={...y.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...y.dismissed,e])],confirm:!1})},N=(e,t)=>P({ingredients:y.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:y.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...y.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=y.photos.length+y.pending.length,F=async e=>{if(D(null),_>=m.MAX_RECIPE_PHOTOS)D('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...y.pending,t]}),D(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){D(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=y.dish||l?.dish||'this dish';return(0,C.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,C.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,C.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:y.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,C.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:y.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,C.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:y.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,C.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,C.jsx)(d.Chip,{label:e,selected:y.section===e,onPress:()=>P({section:e})},e))}),(0,C.jsx)(d.Field,{money:!0,testID:"dish-price",label:"Price (\xa3)",value:y.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Photos"}),(0,C.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,C.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[y.photos.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,photo:e,height:160,index:t+1,total:_||y.photos.length}),(0,C.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:y.photos.filter((e,s)=>s!==t)})})]},e)),y.pending.map((e,t)=>(0,C.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,C.jsx)(k,{dish:U,pending:e.dataUrl,height:160,index:y.photos.length+t+1,total:_}),(0,C.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${y.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${y.photos.length+t+1}`,onPress:()=>P({pending:y.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,C.jsx)(k,{dish:U,height:160})]}),(0,C.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,C.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,C.jsx)(r.default,{testID:"photo-info",children:(0,C.jsx)(d.Muted,{center:!0,children:$})}):(0,C.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Ingredients"}),(0,C.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),y.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsxs)(d.Row,{gap:6,children:[(0,C.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>N(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,C.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>N(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,C.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>N(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:y.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,C.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,C.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...y.ingredients,{id:L(),name:'',qty:'',unit:''}]})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Method"}),y.steps.map((e,n)=>(0,C.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,C.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,C.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,C.jsxs)(r.default,{style:{gap:4},children:[(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,C.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,C.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:y.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,C.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...y.steps,'']})}),(0,C.jsx)(d.Divider,{}),(0,C.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,C.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,C.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,C.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(v,e).join(', ')})`).join('; ')}),E.map(e=>(0,C.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,C.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,C.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...y.allergens,[e]:'contains'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...y.allergens,[e]:'may'},confirm:!1})}),(0,C.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>z(e)})]},e)),(0,C.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...y.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,C.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=y.allergens[e.id],s=O.includes(e.id)&&!t&&!y.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,C.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,C.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),y.dismissed.length?(0,C.jsxs)(d.Muted,{children:["Ruled out: ",y.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,C.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:y.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,C.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:y.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!y.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:y.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,C.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:y.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:y.confirm?o.colours.okBg:'transparent'},children:y.confirm?(0,C.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,C.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),I?(0,C.jsx)(d.Banner,{kind:"danger",children:I}):null,(0,C.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{w(null);const t=M(y.price);if(!y.dish.trim())return w('Give the dish a name.');if('bad'===t)return w('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...y.photos];for(const t of y.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,y.id,t))}const i=y.steps.map(e=>e.trim()).filter(Boolean),r=y.createdBy.trim(),o={dish:y.dish.trim(),section:y.section,price:t,ingredients:v.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:y.allergens,dismissed:y.dismissed,allergenNotes:y.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:y.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:y.id,description:y.description.trim()||void 0},c);y.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){w(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,C.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:y.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?T?(0,C.jsxs)(d.Row,{gap:8,children:[(0,C.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){w(e?.message??'Could not remove the card.')}}}),(0,C.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,C.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const E=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function A(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function z({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,y='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,j=`${e.dish}, ${e.section}, ${$(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,C.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:j,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,C.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,C.jsx)(k,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,C.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,C.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",$(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,C.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,C.jsx)(P,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,C.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:y},children:(0,C.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:y,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,C.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,C.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${I(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1155,[812,779,17,319,385,85,804,777,858,1156,1026,867,845,847,870,1082,1157,840,1158,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1156,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1157,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TAKEAWAY_SWITCH_LABEL",{enumerable:!0,get:function(){return f}}),_e.TakeawaySwitch=function({itemId:e,dish:n,role:h,me:w,signedOff:y,priced:b}){const k=(0,l.useStaffTakeaway)(e=>e.rows),j=(0,l.useStaffTakeaway)(e=>e.canSet),T=(0,l.useStaffTakeaway)(e=>e.busy),x=(0,l.useStaffTakeaway)(t=>t.errorItem===e?t.error:'');(0,t.useEffect)(()=>{(0,l.loadStaffTakeaway)()},[]);const S=k?.[e]??(k&&(0,l.isPitch)()?(0,l.pitchRow)(e):void 0),p={width:'100%',gap:6,paddingVertical:8,paddingHorizontal:12,borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface};if(null===k)return(0,u.jsx)(s.default,{testID:"takeaway-switch-offline",style:p,children:(0,u.jsxs)(o.Muted,{center:!0,children:[f,": connect to the venue to see or change this."]})});if(!S)return null;const v=S.onMenu,_=v&&!y?'Guests can order it for takeaway once it is signed off.':v&&!b?'Guests can order it for takeaway once it has a price.':v?'Guests can order it for collection.':'Guests see it on the takeaway menu as \u201cNot available for takeaway today\u201d.';return(0,u.jsxs)(s.default,{testID:"takeaway-switch-box",style:p,children:[(0,l.showsSwitch)(j,h)?(0,u.jsx)(o.Toggle,{testID:"takeaway-switch",label:f,a11y:`${f}, ${n}`,value:v,disabled:T===e,onChange:t=>{(0,l.setTakeawayAvailable)(e,t,w).catch(()=>{})}}):(0,u.jsxs)(s.default,{accessible:!0,accessibilityLabel:`${f}: ${v?'yes':'no'}. Only the Head Chef, a manager or an owner can change this.`,children:[(0,u.jsxs)(o.T,{testID:"takeaway-switch-readonly",children:[f,": ",v?'Yes':'No']}),(0,u.jsx)(o.Muted,{children:"Only the Head Chef, a manager or an owner can change this."})]}),(0,u.jsx)(o.Muted,{children:_}),x&&null===T?(0,u.jsx)(o.Banner,{kind:"danger",children:x}):null]})};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),l=r(d[4]),u=r(d[5]);const f='Available for takeaway'},1158,[17,85,777,804,1159,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStaffTakeaway",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"showsSwitch",{enumerable:!0,get:function(){return s}}),_e.loadStaffTakeaway=u,_e.setTakeawayAvailable=async function(e,s,l){if(n.PITCH){const t=o.getState().rows??{},n=t[e]??c(e);return void o.setState({rows:{...t,[e]:{...n,onMenu:s}}})}o.setState({busy:e,error:'',errorItem:null});try{await(0,t.setStaffTakeawayDish)(e,s,l),await u(!0);const n=o.getState().rows?.[e];if(!n||n.onMenu!==s)throw new Error('The change didn\u2019t save. Try again.')}catch(t){const n=String(t?.message??'Couldn\u2019t save. Try again.');throw o.setState({errorItem:e,error:/42501|Only the Head Chef/.test(n)?'Only the Head Chef, a manager or an owner can change this.':n}),t}finally{o.setState({busy:null})}},Object.defineProperty(_e,"pitchRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"isPitch",{enumerable:!0,get:function(){return d}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const o=(0,e.create)(()=>({rows:null,canSet:!1,loadedAt:0,error:'',busy:null,errorItem:null})),s=(e,t)=>e&&'staff'!==t;let l=null;function u(e=!1){const s=o.getState();return n.PITCH?(o.setState({rows:s.rows??{},canSet:!0,loadedAt:Date.now(),error:''}),Promise.resolve()):!e&&s.loadedAt&&Date.now()-s.loadedAt<6e4?Promise.resolve():l||(l=(async()=>{try{const[e,n]=await Promise.all([(0,t.staffTakeawayMenu)(),(0,t.staffTakeawayCanSet)()]);o.setState({rows:null===e?null:Object.fromEntries(e.map(e=>[e.itemId,e])),canSet:null!==e&&n,loadedAt:Date.now(),error:''})}catch(e){o.setState({error:String(e?.message??'Couldn\u2019t load the takeaway list.'),loadedAt:Date.now()})}finally{l=null}})(),l)}const c=e=>({itemId:e,dish:'',section:'',pricePence:null,signedOff:!0,onMenu:!0,soldOut:!1}),d=()=>n.PITCH},1159,[831,899,880]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1160,[863]); +__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,"ChatAsCtx",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1161,[887,813,812,822,805,17,1026,319,385,85,777,876,863,804,1057,993,884,1017,1016,899,1085,1071,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1162,[813,17,85,777,860,816,853,804,884,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.gamesOn=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sounds and spoken alerts on':'Mute sounds and spoken alerts',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1163,[887,813,17,378,219,385,85,884,777,885,876,1164,886,816,805,1165,899,804,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1164,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1165,[928,971,899,972]); +__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.KitchenRotaEditor=D,_e.KitchenRotaTab=function({today:e=(0,u.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,c.useSync)(e=>e.perms));return(0,x.jsx)(n.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,x.jsx)(D,{today:e}):(0,x.jsx)(C,{today:e})})},_e.KitchenRotaRead=C;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),a=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),u=_r(_d[12]),m=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]);const j=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],k=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],$=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,p=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,w=e=>e.replace(/\s*\(.*\)$/,''),I=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]],S=e=>e.replace(/\s+/g,'-').toLowerCase();function D({today:e=(0,u.ymd)(new Date)}){const o=(0,l.useOwner)(e=>e.staff),d=(0,l.useOwner)(e=>e.shifts),c=(0,t.useMemo)(()=>(0,r.kitchenTeam)(o),[o]),I=(0,t.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),[S,D]=(0,t.useState)(0),C=(0,b.useDateCalendar)(),[T,H]=(0,t.useState)(null),[L,P]=(0,t.useState)(null),[O,R]=(0,t.useState)(''),B=(0,l.addDays)((0,l.mondayOfDate)(e),7*S),M=(0,l.addDays)(B,6),W=j.map((e,t)=>(0,l.addDays)(B,t)),N=(0,r.kitchenPending)(d,I,B,M).length,z=e=>{R(e),(0,m.announce)(e)},_=0===S?'This week':1===S?'Next week':-1===S?'Last week':`Week of ${p(B)}`;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center',flexWrap:'nowrap'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{D(S-1),R('')},style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${_}, ${k[0]} ${p(B)} to ${k[6]} ${p(M)}`,style:{alignItems:'center',minWidth:120,flex:1},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:_}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(B)," \u2013 ",$(M)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{D(S+1),R('')},style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:C.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:C.calOpen,today:e,day:B,showBusy:!0,idPrefix:"krota-cal",onClose:C.closeCal,onDay:t=>{D((0,b.weekOffsetOf)(t??e,e)),R('')}}),c.map(t=>(0,x.jsxs)(n.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{size:14,weight:"semibold",center:!0,children:[w(t.nickname||t.name),t.job?(0,x.jsx)(a.T,{size:12,colour:y.colours.muted,children:` ${t.job}`}):null]}),(0,x.jsx)(a.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:W.map((n,i)=>{const l=d.find(e=>e.staffId===t.id&&e.date===n),r=!(!l||l.published&&!l.changed),o=(0,f.cleanBadge)(l?.badge),c=`${w(t.nickname||t.name)}, ${k[i]} ${p(n)}, ${l?`${(0,h.fmtH)(l.start)} to ${(0,h.fmtH)(l.end)}${(0,f.badgeSpoken)(l.badge)}${r?', draft, not published yet':''}. Change shift or role`:'off. Add a shift'}`;return(0,x.jsxs)(s.default,{testID:`krota-cell-${t.id}-${i}`,accessibilityRole:"button",accessibilityLabel:c,onPress:()=>{l?P({staffId:t.id,date:n,shift:l}):H({staffId:t.id,date:n})},style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:r?'dashed':'solid',borderColor:l?r?y.colours.amber:y.colours.gold:y.colours.border,backgroundColor:e||l?y.colours.goldTint:y.colours.surface2}),children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:n===e?y.colours.gold:y.colours.muted,children:j[i]}),(0,x.jsx)(a.T,{size:10,center:!0,children:l?`${(0,h.fmtH)(l.start).slice(0,5)}`:'off'}),l?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(l.end).slice(0,5)}):(0,x.jsx)(a.T,{size:10,center:!0,colour:y.colours.muted,children:"+"}),o?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,testID:`krota-badge-${t.id}-${i}`,children:o}):null]},n)})})]},t.id)),c.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,x.jsx)(a.Button,{testID:"krota-publish",kind:N?'primary':'secondary',disabled:!N,label:N?`Publish kitchen rota (${N} ${1===N?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:N?`Publish the kitchen rota for ${_.toLowerCase()}, ${N} ${1===N?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(l.useOwner.getState().shifts,I,B,M);l.useOwner.getState().setShifts(e.shifts),z(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),O?(0,x.jsx)(n.default,{testID:"krota-msg",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.goldLight,children:O})}):null,(0,x.jsx)(a.Muted,{center:!0,children:"Tap a day to add a shift, or tap a shift to assign a kitchen role or change the times. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),L?(0,x.jsx)(i.AssignRoleSheet,{name:w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??''),when:`${(0,u.niceDate)((0,u.parseYmd)(L.date))} \xb7 ${(0,h.fmtH)(L.shift.start)}\u2013${(0,h.fmtH)(L.shift.end)}`,current:L.shift.badge,roles:f.KITCHEN_ROLE_BADGES,onSave:e=>{l.useOwner.getState().setShifts((0,f.assignKitchenShiftBadge)(l.useOwner.getState().shifts,L.shift.id,e)),z(`${w((o.find(e=>e.id===L.staffId)?.nickname||o.find(e=>e.id===L.staffId)?.name)??'')}, ${(0,u.niceDate)((0,u.parseYmd)(L.date))}${e?`, on ${e}`:', role cleared'}. Draft until you publish the kitchen rota.`),P(null)},onEditTimes:()=>{H(L),P(null)},onClose:()=>P(null)}):null,T?(0,x.jsx)(v,{init:T,onClose:()=>H(null),onSaid:z}):null]})}function C({today:e=(0,u.ymd)(new Date)}){const{staff:s,shifts:i}=(0,d.rotaView)('chef',(0,l.useOwner)(e=>e.staff),(0,l.useOwner)(e=>e.shifts)),r=(0,l.useOwner)(e=>e.leave),[c,m]=(0,t.useState)(0),I=(0,b.useDateCalendar)(),S=(0,l.addDays)((0,l.mondayOfDate)(e),7*c),D=(0,l.addDays)(S,6),C=j.map((e,t)=>(0,l.addDays)(S,t)),v=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),T=0===c?'This week':1===c?'Next week':-1===c?'Last week':`Week of ${p(S)}`,[H,L]=(0,t.useState)(0),P=H?Math.max(30,Math.min(44,Math.floor((H-12)/7))):40;return(0,x.jsxs)(n.default,{testID:"kitchen-rota-read",onLayout:e=>L(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,x.jsxs)(a.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>m(c-1),style:{minWidth:84,minHeight:48}}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${T}, ${k[0]} ${p(S)} to ${k[6]} ${p(D)}`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(a.T,{weight:"semibold",center:!0,children:T}),(0,x.jsxs)(a.Muted,{center:!0,children:[$(S)," \u2013 ",$(D)]})]}),(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>m(c+1),style:{minWidth:84,minHeight:48}})]}),(0,x.jsx)(n.default,{style:{alignItems:'center'},children:(0,x.jsx)(a.Button,{small:!0,kind:"ghost",testID:"krota-read-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:I.openCal,style:{minWidth:84,minHeight:48}})}),(0,x.jsx)(b.AppDateCalendar,{visible:I.calOpen,today:e,day:S,showBusy:!0,idPrefix:"krota-read-cal",onClose:I.closeCal,onDay:t=>m((0,b.weekOffsetOf)(t??e,e))}),v.map(t=>(0,x.jsxs)(n.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(a.T,{size:14,weight:"semibold",center:!0,children:w(t.nickname||t.name)}),(0,x.jsx)(a.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:C.map((s,l)=>{const d=i.find(e=>e.staffId===t.id&&e.date===s),c=d?(0,o.leaveCovering)(r,t.id,s):void 0,u=(0,f.cleanBadge)(d?.badge),m=d?c?(0,o.leaveLabel)(c):`${(0,h.fmtH)(d.start)} to ${(0,h.fmtH)(d.end)}${(0,f.badgeSpoken)(d.badge)}`:'off';return(0,x.jsxs)(n.default,{testID:`krota-read-cell-${t.id}-${l}`,accessible:!0,accessibilityLabel:`${w(t.nickname||t.name)}, ${k[l]} ${p(s)}, ${m}`,style:{width:P,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d?y.colours.gold:y.colours.border,backgroundColor:d?y.colours.goldTint:y.colours.surface2},children:[(0,x.jsx)(a.T,{size:10,center:!0,colour:s===e?y.colours.gold:y.colours.muted,children:j[l]}),d&&c?(0,x.jsx)(a.T,{size:9,center:!0,colour:y.colours.blue,children:(0,o.leaveLabel)(c).toLowerCase()}):(0,x.jsx)(a.T,{size:10,center:!0,children:d?(0,h.fmtH)(d.start).slice(0,5):'off'}),d&&!c?(0,x.jsx)(a.T,{size:10,center:!0,children:(0,h.fmtH)(d.end).slice(0,5)}):null,u&&!c?(0,x.jsx)(a.T,{size:8,center:!0,colour:y.colours.gold,numberOfLines:1,children:u}):null]},s)})})]},t.id)),v.length?null:(0,x.jsx)(a.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,x.jsx)(a.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function v({init:e,onClose:s,onSaid:i}){const o=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=w(o?.nickname||o?.name||''),[c,m]=(0,t.useState)(e.shift?.start??11),[b,j]=(0,t.useState)(e.shift?.end??21),[k,$]=(0,t.useState)((0,f.cleanBadge)(e.shift?.badge)),[D,C]=(0,t.useState)(!1),[v,T]=(0,t.useState)(''),H=`${(0,u.niceDate)((0,u.parseYmd)(e.date))} (${p(e.date)})`;return(0,x.jsx)(a.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${H}`,testID:"krota-sheet",children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'center'},children:[(0,x.jsx)(a.T,{center:!0,weight:"semibold",children:"Kitchen role for this shift"}),(0,x.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(a.Chip,{label:"None",selected:!k,onPress:()=>$(void 0),testID:"krota-badge-none"}),f.KITCHEN_ROLE_BADGES.map(e=>(0,x.jsx)(a.Chip,{label:e,selected:k===e,onPress:()=>$(k===e?void 0:e),testID:`krota-badge-${S(e)}`,accessibilityLabel:`${e}${k===e?', chosen, tap to remove':''}`},e))]}),(0,x.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:I.map(([e,t,s])=>(0,x.jsx)(a.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,h.fmtH)(t)}\u2013${(0,h.fmtH)(s)}`,selected:c===t&&b===s,onPress:()=>{m(t),j(s)}},e))}),(0,x.jsx)(a.T,{center:!0,children:"Start"}),(0,x.jsx)(a.Stepper,{testID:"krota-start",value:c,step:.5,min:h.SHIFT_MIN_START,max:b-1,onChange:m,format:h.fmtH,label:"Start time"}),(0,x.jsxs)(a.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,x.jsx)(a.Stepper,{testID:"krota-end",value:b,step:.5,min:c+1,max:h.SHIFT_MAX_END,onChange:j,format:h.fmtH,label:"End time"}),(0,x.jsxs)(a.Muted,{center:!0,children:[(b-c).toFixed(1)," hours"]}),v?(0,x.jsx)(n.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(a.T,{center:!0,colour:y.colours.amber,children:v})}):null,(0,x.jsx)(a.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${k?`, on ${k}`:''}`,onPress:()=>{const t=l.useOwner.getState();if((0,r.clashes)(t.shifts,e.staffId,e.date,c,b,e.shift?.id))return void T(`${d} already has a shift that overlaps on ${H}.`);const n=(0,f.cleanBadge)(k);e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:c,end:b,badge:n,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:c,end:b,...n?{badge:n}:{}}),i(`${e.shift?'Changed':'Added'}: ${d}, ${H}, ${(0,h.fmtH)(c)} to ${(0,h.fmtH)(b)}${n?`, on ${n}`:''}. Draft until you publish the kitchen rota.`),s()},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!D?(0,x.jsx)(a.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>C(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&D?(0,x.jsxs)(n.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsxs)(a.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",H,"?"]}),(0,x.jsx)(a.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{l.useOwner.getState().removeShift(e.shift.id),i(`Removed ${d}'s shift on ${H}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,x.jsx)(a.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>C(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1166,[17,385,85,777,1167,876,902,1071,909,899,1060,1168,863,1097,1051,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssignRoleSheet=function({name:e,when:s,current:u,onSave:b,onEditTimes:y,onClose:_,roles:j=o.ROLE_BADGES}){const w={minHeight:l.IS_CAR?64:56,width:'100%'},x=(0,o.cleanBadge)(u),E=new Set((j??o.ROLE_BADGES).map(e=>e.toLowerCase()));return(0,c.jsxs)(n.Sheet,{visible:!0,onClose:_,title:"Assign a role?",testID:"assign-role-sheet",maxWidth:560,children:[(0,c.jsx)(n.T,{size:18,center:!0,weight:"semibold",children:e}),(0,c.jsx)(n.Muted,{center:!0,children:s}),(0,c.jsxs)(t.default,{style:{gap:8,width:'100%'},children:[o.ROLE_BADGES.map(e=>E.has(e.toLowerCase())?(0,c.jsx)(n.Button,{kind:x===e?'primary':'secondary',label:e,testID:`assign-role-${h(e)}`,accessibilityLabel:`${e}${x===e?', chosen':''}`,onPress:()=>b(e),style:w},e):null),(0,c.jsx)(n.Button,{kind:x?'secondary':'primary',label:"None",testID:"assign-role-none",accessibilityLabel:x?'None, clear the role badge':'None, chosen',onPress:()=>b(void 0),style:w}),y?(0,c.jsx)(n.Button,{kind:"ghost",label:"Edit shift times",testID:"assign-role-edit-times",onPress:y,style:w}):null]})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]);const h=e=>e.replace(/\s+/g,'-').toLowerCase()},1167,[17,85,777,1168,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FOH_ROLE_BADGES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"KITCHEN_ROLE_BADGES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ROLE_BADGES",{enumerable:!0,get:function(){return o}}),e.cleanBadge=c,Object.defineProperty(e,"isKitchenBadge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isFohBadge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"badgeSpoken",{enumerable:!0,get:function(){return f}}),e.assignShiftBadge=b,e.assignKitchenShiftBadge=function(n,t,o){const s=String(o??'').trim();return s&&!u(s)?n:b(n,t,s?c(s):void 0)},e.applyLiveKitchenBadge=function(n,t,o){const s=String(o??'').trim();if(s&&!u(s))return n;const f=s?c(s):void 0;return n.map(n=>n.id===t?{...n,badge:f}:n)};const n=['Bar','Floor'],t=['Upstairs KP','Downstairs KP','Sauce','Larder'],o=[...n,...t];function c(n){const t=String(n??'').trim().toLowerCase();return o.find(n=>n.toLowerCase()===t)}const u=n=>{const o=c(n);return!!o&&t.includes(o)},s=t=>{const o=c(t);return!!o&&n.includes(o)},f=n=>c(n)?`, on ${c(n)}`:'';function b(n,t,o){const u=c(o);return n.map(n=>n.id===t?{...n,badge:u,changed:!!n.published||n.changed}:n)}},1168,[]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1169,[1152,896,17,362,85,777,876,909,851,804,1057,1144,1002,1170,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.openLink=w,_e.useSheetReminders=C,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=C(),f=(0,b.wd)(l);return(0,j.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,j.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,j.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,j.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,j.jsx)($,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,j.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);function w(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function k(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const S={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},T={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function C(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function $({s:e,open:n,onToggle:o}){const{rid:C,r:$,me:D,now:I}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),M=(0,u.useOrderSheets)(e=>e.markOpened),B=(0,u.useOrderSheets)(t=>t.opened[e.id]),[L,P]=(0,s.useState)({}),[O,R]=(0,s.useState)(''),[A,z]=(0,s.useState)(''),[_,W]=(0,s.useState)(!1),H=(0,h.useShellfish)(C,D,'chef'),K=(0,b.nextDelivery)(e,I),E=(0,b.orderLines)(e,L,O,C),N=($.address??$.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=N.length>=3?N[1]:N[0]??'',U=(0,b.orderMessage)(e,$.name,q,E,D.split(' ')[0],I),Q=e.orderDays.includes((0,b.wd)(I)),Y=(e,t)=>P(n=>({...n,[e.id]:(0,l.stepQuantity)(C,e,n[e.id]||0,t)})),F=t=>{M(e.id,I.toISOString()),w(t)},G='text'===e.method||'whatsapp'===e.method||'phone'===e.method,V=Math.round(100*((0,y.parseMoneyInput)(A)??NaN)),J=H.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),X=J.filter(e=>H.isLow(e.key));return(0,j.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:Q||X.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,j.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[S[e.method]," ",e.name]}),(0,j.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,j.jsx)(i.Muted,{children:e.goods}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,j.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,j.jsx)(i.Badge,{kind:Q?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,j.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,j.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,J.length?(0,j.jsx)(i.Badge,{kind:X.length?'amber':'ok',label:J.map(e=>`${e.icon} ${(0,c.fmtStockCount)(C,e,H.counts[e.key]??0)}`).join(' \xb7 ')}):null,B&&new Date(B).toDateString()===I.toDateString()?(0,j.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,j.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[K?(0,j.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(K),"."]}):null,e.reminder?(0,j.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,j.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,j.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,j.jsxs)(d.default,{style:{gap:6},children:[(0,j.jsxs)(i.T,{children:[e.name,e.unit?(0,j.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(C,e),")"]}):null]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Y(e,-1),style:{minWidth:44,minHeight:44}}),(0,j.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(C,e,L[e.id]||0),children:(0,j.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(C,e)?(0,l.fishQtyText)(C,e,L[e.id]||0):L[e.id]||0})}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(C,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Y(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,j.jsx)(t.TextInput,{value:O,onChangeText:R,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[T,{minHeight:60}]})]}),G?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(C,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,'online'===e.method?(0,j.jsxs)(d.default,{style:{gap:4},children:[(0,j.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,j.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(C,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:T})]}):null,e.priceCapPerKg?(0,j.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,j.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,j.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,j.jsx)(t.TextInput,{testID:"price-found",value:A,onChangeText:e=>z((0,y.sanitiseMoneyTyping)(e)),keyboardType:"decimal-pad",inputMode:"decimal",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[T,{width:120}]})]}),V>0?(0,j.jsx)(i.Badge,{kind:V<=e.priceCapPerKg?'ok':'red',label:V<=e.priceCapPerKg?`${(0,p.gbp)(V)}/kg is under the cap \u2713`:`${(0,p.gbp)(V)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,j.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,j.jsx)(i.T,{size:f.font.small,children:E.length?U:'Add quantities above to write the order.'})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!E.length,onPress:()=>F((0,b.smsLink)(e.number,U))}):null,'whatsapp'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!E.length,onPress:()=>F((0,b.waLink)(e.number,U))}):null,'phone'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>F((0,b.telLink)(e.number))}):null,'online'===e.method?(0,j.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>F(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&E.length?(0,j.jsx)(i.Button,{kind:"ghost",label:_?'Copied \u2713':'Copy order',onPress:async()=>{const e=await k(U);W(e),e&&setTimeout(()=>W(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&E.length?(0,j.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,j.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,j.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1170,[812,820,896,17,362,219,385,85,777,1000,895,897,851,1001,804,1144,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}),Object.defineProperty(_e,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=$,_e.useReservedTomorrow=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:n,onOrder:l,style:d,readOnly:m=!1}){const b=(0,h.useShellfish)(e,t,s),f=$(e),[p,k]=(0,o.useState)(!1),x=T(e,b.items.find(e=>e.supplierId)?.supplierId),v=(0,r.useLiveState)();if('ready'!==v)return(0,j.jsx)(r.LiveWait,{state:v,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!b.items.length)return null;const w=b.items.filter(e=>b.isLow(e.key)),C=b.items.length<=3?b.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,j.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:w.length?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface,padding:n?10:12,gap:6},d],children:[(0,j.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${b.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)}`).join(', ')}${m?'':'. Tap to update'}`,onPress:()=>{m||k(!0)},disabled:m,style:{gap:4,flex:n?1:void 0},children:[(0,j.jsxs)(c.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:["LIVE \xb7 ",C]}),m?null:(0,j.jsx)(c.T,{size:12,colour:y.colours.muted,children:"Tap to update \u203a"})]}),(0,j.jsx)(c.Row,{gap:n?14:18,style:{flex:n?1:void 0,alignItems:'center'},children:b.items.map(t=>{const s=b.counts[t.key]??0,o=b.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,j.jsx)(c.T,{size:n?42:34,weight:"bold",colour:s<=0?y.colours.red:o?y.colours.amber:y.colours.text,style:{lineHeight:n?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,j.jsxs)(c.T,{size:13,colour:o?y.colours.amber:y.colours.muted,children:[S(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,j.jsxs)(c.T,{size:12,weight:"semibold",colour:y.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!n&&w.length?(0,j.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:y.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,j.jsxs)(c.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",w.map(t=>`${(0,u.fmtStockCount)(e,t,b.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,j.jsx)(c.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,n||w.length||!l?null:(0,j.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,j.jsx)(c.T,{size:13,colour:y.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:r=76}){const l=(0,h.useShellfish)(e,t,s),d=$(e),[m,b]=(0,o.useState)(!1);if(!l.items.length)return null;const f=r>=80,p=Math.max(28,Math.min(52,Math.round(.6*r))),k=Math.max(22,Math.min(34,Math.round(.42*r)));return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>b(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:r,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...n.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=d[t.key]??0,h=Math.max(0,o-i),m=h<=0,b=m||l.isLow(t.key);return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:f?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:b?'rgba(255,107,94,0.07)':'transparent',...n.look.web(b?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,j.jsx)(w,{icon:t.icon,size:k}),(0,j.jsx)(c.T,{size:p,weight:"bold",colour:b?'#FF8E82':y.colours.text,style:{lineHeight:Math.round(1.15*p),letterSpacing:-.5,minWidth:Math.round(.85*p),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,j.jsxs)(a.default,{style:{gap:0},children:[(0,j.jsx)(c.T,{size:f?15:13,weight:"semibold",colour:b?'#FFB3AA':y.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),b&&r>=60?(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:m?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,j.jsxs)(c.T,{size:f?14:12,weight:"semibold",colour:i?y.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),m?(0,j.jsx)(D,{rid:e,by:t,app:s,onClose:()=>b(!1)}):null]})},_e.ShellfishPanel=D,Object.defineProperty(_e,"SHELLFISH_CHIP_N_SLOT",{enumerable:!0,get:function(){return M}}),_e.ShellfishChip=z,_e.SundayRoastChip=function(e){return(0,j.jsx)(z,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),m=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),p=_r(_d[16]),k=_r(_d[17]),x=_r(_d[18]),j=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?d.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,j.jsx)(c.T,{size:t,children:e});const o=Math.round(1.25*t),r=o/Math.max(s.w,s.h);return(0,j.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,j.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*r),height:Math.round(s.h*r)},resizeMode:"contain"})})}const S=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),C=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function $(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=(0,p.venueYmd)((0,b.useNow)(6e4));return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}const I=(e,t)=>{const[s,o,r]=e.split('-').map(Number),n=new Date(Date.UTC(s,o-1,r+t));return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,'0')}-${String(n.getUTCDate()).padStart(2,'0')}`};function L(e){const t=(0,b.useBookings)(e),s=(0,b.useRestaurant)(e),o=I((0,p.venueYmd)((0,b.useNow)(6e4)),1);return(0,f.reservedOn)(t,o,(0,f.reservablesOf)(s))}function T(e,t){const s=(0,m.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function D({rid:e,by:s,app:r,onClose:n,onOrder:l,group:i}){const d=(0,h.useShellfish)(e,s,r,i),m='roast'===i,[b,f]=(0,o.useState)({}),p=m?Object.fromEntries(d.items.map(e=>[e.key,b[e.key]??Math.max(0,Math.round(d.counts[e.key]??0))])):b,[v,w]=(0,o.useState)(null),$=T(e,d.items.find(e=>e.supplierId)?.supplierId),I=(s,o)=>{const r=d.itemOf(s);r&&f(n=>{const l=n[s]??(m?Math.max(0,Math.round(d.counts[s]??0)):0);return{...n,[s]:(0,t.fishInStone)(e,r)?(0,t.stepQuantity)(e,r,l,o):Math.max(0,Math.min(99,l+o))}})},L=(e,t=!1)=>{const s=d.itemOf(e);d.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(p).reduce((e,t)=>e+t,0),M=m&&d.items.some(e=>null!=b[e.key]&&b[e.key]!==Math.round(d.counts[e.key]??0)),z=(0,o.useRef)(null);z.current||(z.current=new Set(d.events.map(e=>e.id)));const O=d.events.filter(e=>!z.current.has(e.id)),[R,E]=(0,o.useState)({state:'idle'}),[B,F]=(0,o.useState)(0),H=O.filter(e=>'saved'!==(0,x.stockEventStatus)(e.id).state),A=m?M:D>0,P=(e,t)=>{E({state:e,text:t}),(0,k.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==R.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[R.state,H.length]);const W=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==R.state)return;const e=O.map(e=>e.id).map(e=>(0,x.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void P('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,x.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?P('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?P('saved',m?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-W.current>2e4&&P('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[R.state,B,O.length]);const N='saving'!==R.state&&(A||H.length>0),_='saving'===R.state?'Saving\u2026':'saved'!==R.state||A||H.length?'error'===R.state?R.text:N?A?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':R.text,U=(0,j.jsxs)(a.default,{testID:m?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,j.jsx)(c.Button,{testID:m?'roast-save':'shellfish-save',kind:"primary",label:'saving'===R.state?'Saving\u2026':'Save changes',disabled:!N,accessibilityLabel:'saving'===R.state?'Saving':N?'Save changes':'Save changes, nothing to save',onPress:()=>{m&&M&&(d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({})),!m&&D&&(d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),f({})),W.current=Date.now(),E({state:'saving',text:'Saving\u2026'}),(0,k.announce)('Saving'),setTimeout(()=>{(0,x.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,j.jsx)(a.default,{testID:m?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,j.jsx)(c.T,{center:!0,size:14,colour:'error'===R.state?'#FFB3AA':'saved'===R.state?y.colours.goldLight:y.colours.muted,children:_})})]});return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:n,title:m?`Sunday roast: ${d.items.map(e=>e.plural).join(' & ')}`:d.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:m?'roast-panel':'shellfish-panel',footer:U,children:[(0,j.jsx)(c.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:d.items.map(s=>{const o=d.counts[s.key]??0;return(0,j.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:d.isLow(s.key)?y.colours.amber:y.colours.border,backgroundColor:y.colours.surface2},children:[(0,j.jsx)(c.T,{center:!0,size:13,colour:y.colours.muted,children:S(s)}),(0,j.jsx)(c.T,{center:!0,size:48,weight:"bold",colour:d.isLow(s.key)?y.colours.amber:y.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,j.jsx)(c.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>L(s.key),style:{minHeight:56}}),'half'===s.unit?(0,j.jsx)(c.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>L(s.key,!0),style:{minHeight:52}}):(0,j.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,j.jsx)(c.Button,{kind:"ghost",label:d.undoable?`\u21b6 Undo: ${(0,u.describe)(d.undoable,d.itemOf(d.undoable.kind))}`:'\u21b6 Nothing to undo',testID:m?'roast-undo':'shellfish-undo',disabled:!d.undoable,onPress:()=>{const e=d.undoable;d.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,d.itemOf(e.kind))}.`)}}),v?(0,j.jsx)(c.Banner,{kind:"success",title:v}):null,(0,j.jsxs)(a.default,{testID:m?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint},children:[(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.goldLight,children:m?'Count before service':'Delivery in'}),d.items.map(s=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(c.T,{style:{flex:1},children:S(s)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:m?`One less ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>I(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,j.jsx)(c.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,p[s.key]||0)}),(0,j.jsx)(c.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:m?`One more ${s.name.toLowerCase()}, now ${p[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>I(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,j.jsx)(c.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>I(s.key,5)})]},s.key)),m?(0,j.jsx)(c.Button,{kind:"success",label:`Set today\u2019s count: ${d.items.map(e=>`${p[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!M,onPress:()=>{d.items.forEach(e=>{null!=b[e.key]&&d.recount(e.key,Math.max(0,Math.round(b[e.key])))}),f({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,j.jsx)(c.Button,{kind:"success",label:D?`Add to stock: ${d.items.filter(e=>p[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,p[t.key])} ${(1===p[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{d.items.forEach(e=>d.deliver(e.key,p[e.key]??0)),w('Delivery added to the count.'),f({})},style:{minHeight:54}})]}),l?(0,j.jsx)(c.Button,{kind:"secondary",label:$?`${$} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,j.jsxs)(a.default,{style:{gap:2},children:[(0,j.jsx)(c.T,{size:12,weight:"semibold",colour:y.colours.gold,children:"RECENT"}),d.events.slice(0,6).map(e=>(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{size:13,style:{flex:1},children:(0,u.describe)(e,d.itemOf(e.kind))}),(0,j.jsxs)(c.Muted,{children:[C(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,j.jsx)(c.Row,{wrap:!0,gap:6,children:d.synced?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"ok",label:"Shared live"}),(0,j.jsx)(c.Muted,{children:"Every paired device sees the same count."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.Badge,{kind:"neutral",label:"Saved on this device"}),(0,j.jsx)(c.Muted,{children:"Not connected to the shared venue yet."})]})})]})}const M=18;function z({rid:e,by:t,app:r,size:l="m",group:d,slot:m=!1}){const f=(0,h.useShellfish)(e,t,r,d),p=$(e),k=L(e),[x,S]=(0,o.useState)(!1),[C,I]=(0,o.useState)(null),T=(0,b.useNow)(3e4);if(!f.items.length)return null;if('roast'===d&&!(0,u.isSundayIn)(T))return null;const z='m'===l?20:17,R='roast'!==d,E=R&&f.items.some(e=>(k[e.key]??0)>0),B=E?Math.max(0,...f.items.map(e=>k[e.key]??0)):0,F='xs'!==l&&!E;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:'roast'===d?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===d?'Sunday roast: ':''}${f.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(f.counts[t.key]??0)-(p[t.key]??0)))} available${R&&k[t.key]?`, ${k[t.key]} reserved tomorrow`:''}`).join(', ')}. Tap to update`,onPress:()=>S(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',justifyContent:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...n.look.web({cursor:'pointer'})}),children:f.items.map((t,o)=>{const n=f.counts[t.key]??0,l=p[t.key]??0,d=Math.max(0,n-l),h=d<=0,m=h||f.isLow(t.key),b=R?k[t.key]??0:0,x=h?y.colours.red:R&&'display'!==r?y.colours.shellfishFree:m&&!R?y.colours.amber:y.colours.text,S=`(${(0,u.fmtStockCount)(e,t,b>0?b:0)})`;return(0,j.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,d)}${b?`, ${b} reserved tomorrow`:''}`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:E?4:6,paddingHorizontal:E?5:9,paddingVertical:3,flexShrink:0,minWidth:E?62:void 0,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:m?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,j.jsx)(c.T,{size:Math.max(11,z-7),weight:"semibold",colour:y.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,j.jsx)(w,{icon:t.icon,size:z-2}),(0,j.jsx)(c.T,{size:z,weight:"bold",colour:x,style:{lineHeight:z+4},children:(0,u.fmtStockCount)(e,t,d)}),b>0?(0,j.jsx)(i.default,{testID:`reserved-tomorrow-${t.key}`,accessibilityRole:"button",accessibilityLabel:`${b} ${t.plural} reserved tomorrow. Opens the list of bookings.`,onPress:e=>{e?.stopPropagation?.(),I(t.key)},hitSlop:12,style:{flexShrink:0,justifyContent:'center',alignItems:'center',width:M,minWidth:M,overflow:'hidden'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:y.colours.red,center:!0,children:S})}):E?(0,j.jsx)(a.default,{testID:`reserved-tomorrow-slot-${t.key}`,accessible:!1,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{minWidth:M,width:M,flexShrink:0,overflow:'hidden',justifyContent:'center',alignItems:'center'},children:(0,j.jsx)(c.T,{size:11,weight:"semibold",colour:"transparent",center:!0,children:`(${(0,u.fmtStockCount)(e,t,B)})`})}):null,!F||!(l||h||m)||h&&s.IS_CAR?null:(0,j.jsx)(c.T,{size:10,weight:"semibold",colour:h||m?'#FFB3AA':y.colours.goldLight,children:h?'none left':l?`${(0,u.fmtStockCount)(e,t,l)} res`:'low'})]},t.key)})}),x?(0,j.jsx)(D,{rid:e,by:t,app:r,group:d,onClose:()=>S(!1)}):null,C?(0,j.jsx)(O,{rid:e,stockKey:C,label:f.items.find(e=>e.key===C)?.plural??C,onClose:()=>I(null)}):null]})}function O({rid:e,stockKey:t,label:s,onClose:o}){const r=(0,b.useBookings)(e),n=(0,b.useRestaurant)(e),l=I((0,p.venueYmd)((0,b.useNow)(6e4)),1),i=(0,f.reservedBookingsOn)(r,l,(0,f.reservablesOf)(n),t),d=s.charAt(0).toUpperCase()+s.slice(1);return(0,j.jsxs)(c.Sheet,{visible:!0,onClose:o,title:`${d} reserved tomorrow`,testID:`reserved-tomorrow-sheet-${t}`,children:[(0,j.jsx)(c.T,{size:16,colour:y.colours.muted,children:(0,p.niceDateYear)((0,p.parseYmd)(l))}),i.map(({booking:e,qty:t})=>(0,j.jsxs)(a.default,{testID:`reserved-tomorrow-row-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:y.colours.hairline,gap:4},children:[(0,j.jsx)(c.T,{size:18,weight:"semibold",children:e.name}),(0,j.jsxs)(c.T,{size:15,colour:y.colours.muted,children:[(e.time||'').slice(0,5)," \xb7 ",e.partySize," ",1===e.partySize?'cover':'covers']}),(0,j.jsxs)(c.T,{size:15,weight:"semibold",colour:y.colours.red,children:[t," reserved"]})]},e.id))]})}},1171,[896,856,17,898,1172,319,385,85,1173,777,897,895,1000,804,858,1055,863,1097,899,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return n}}),r(d[0]);var o=r(d[1]);const b=o=>o,n={panel:{backgroundColor:'#121110',borderRadius:o.radii.xl,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(b,n="gold")=>({minHeight:o.control.tall,borderRadius:o.radii.button,borderWidth:1,borderColor:'blue'===n?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:b?'rgba(207,164,95,0.16)':'blue'===n?'rgba(226,196,137,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),primary:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:b}},1172,[219,811]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1173,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,y.jsxs)(r.default,{style:{gap:12},children:[(0,y.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,y.jsx)(j,{}):'take'===t?(0,y.jsx)(f,{}):(0,y.jsx)(v,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]),y=_r(_d[14]);function j(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[x,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===x?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,y.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,y.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,y.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,y.jsx)(p.Seg,{value:x,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,y.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,y.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,y.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,y.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,y.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,y.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,y.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function f(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[x,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=x[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,y.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,y.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,y.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,y.jsx)(o.T,{size:16,children:e.name}),(0,y.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:x[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(x[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:x[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,y.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,y.jsx)(o.Muted,{children:"\u2014"}):(0,y.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,y.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,y.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,y.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function v(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,y.jsxs)(r.default,{style:{gap:10},children:[(0,y.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,y.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,y.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(r.default,{style:{flex:1},children:[(0,y.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,y.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,y.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,y.jsx)(k,{id:e.id,me:t}):null]},e.id)})]})}function k({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[j,f]=(0,l.useState)(b.lines.map(e=>({...e}))),v=(e,t)=>f(i=>i.map(i=>i.ing===e?{...i,...t}:i)),k='expected'!==b.status,S=(0,l.useMemo)(()=>j.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),$=S.filter(e=>Math.abs(e.pct)>=.5),C=j.reduce((e,t)=>e+t.received*t.price,0);return(0,y.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[S.map(({l:e,i:i,short:l,pct:d})=>(0,y.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,y.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,y.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,y.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>v(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!k?(0,y.jsxs)(o.Row,{children:[(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>v(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,y.jsxs)(o.Row,{gap:4,children:[(0,y.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,y.jsx)(t.TextInput,{editable:!k,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",inputMode:"decimal",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>v(e.ing,{price:100*((0,x.parseMoneyInput)(t)??0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,y.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,y.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round(C))]}),w.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[w.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,$.length?(0,y.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[$.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,k?(0,y.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,y.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,j,i,[w.length?`${w.length} short`:'',$.length?`${$.length} price changes`:''].filter(Boolean).join(', '))})]})}},1174,[812,1000,1152,896,17,385,85,777,876,851,804,1144,1002,840,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1175,[]); +__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.usePay=T,_e.periodPay=P,_e.MyHoursPay=k,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),T=(0,a.useOwner)(e=>e.staff),M=(0,i.useMemo)(()=>T.filter(e=>e.active),[T]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:v,rid:N}=(0,y.useCtx)(6e4),B=(0,b.useVenuePay)(N).pay,[O,L]=(0,i.useState)(-1),[$,S]=(0,i.useState)(null),[H,I]=(0,i.useState)(''),[W,E]=(0,i.useState)(null),_=(0,i.useMemo)(()=>M.map(e=>({...P(e.id,O,v,R,D[e.id]??0,B,z),person:e})),[M,O,R,D,B,z]),V=_.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),F=_[0]?.label??'',G=M.find(e=>e.id===$),A=Math.round(100*Number(H));return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,x.jsxs)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,x.jsx)(C,{label:F,offset:O,setOffset:L,badge:0===O?'Current period':void 0}),(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),_.map(e=>(0,x.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:w(e.person.name)}),c&&e.person.noTax?(0,x.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{S(e.person.id),I(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,x.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]S(null),title:`Hourly rate: ${w(G?.name)}`,children:[(0,x.jsx)(l.Muted,{children:G?`${G.level??a.ROLE_LABEL[G.role]} \xb7 ${G.job}${G.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(G,D[G.id],u.gbp)}`:''}),(0,x.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",inputMode:"decimal",value:H,onChangeText:e=>I((0,f.sanitiseMoneyTyping)(e)),style:l.styles.input}),Number.isFinite(A)&&A>0&&A{a.useOwner.getState().setRate($,A),S(null)}}),$&&null!=D[$]?(0,x.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate($),S(null)}}):null]}),(0,x.jsx)(l.Sheet,{visible:!!W,onClose:()=>E(null),title:`What ${w(M.find(e=>e.id===W)?.name)} sees`,children:W?(0,x.jsx)(k,{staffId:W}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]),x=_r(d[15]);const w=e=>(e??'').replace(' (example)',''),j='Before tax and deductions, estimate';function T(e,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>P(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function P(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*o),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function C({label:e,offset:s,setOffset:t,badge:i}){return(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,x.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e}),i?(0,x.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function k({staffId:e}){const{meId:s,now:f,rid:k}=(0,y.useCtx)(6e4),M=e??s,D=(0,b.useVenuePay)(k).pay,R=(0,a.useOwner)(e=>e.staff).find(e=>e.id===M),z=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[M]??0,O=null!=N[M],[L,$]=(0,i.useState)(0),S=T(M,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...P(M,e,f,z,B,D,v)})),[M,z,B,D,v]);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(l.Banner,{kind:"info",title:j,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,x.jsxs)(l.Muted,{children:[w(R?.name)," \xb7 ",R?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,x.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Confirmed paid hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,x.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Gross pay from hours"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{children:"Tips allocated"}),(0,x.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,x.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,x.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,x.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,x.jsxs)(l.Muted,{children:[j,". Tips are shown separately and only once a tip period is approved."]})]}),(0,x.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,x.jsxs)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,x.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,x.jsxs)(l.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,x.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,x.jsx)(t.WideTable,{children:(0,x.jsxs)(n.default,{children:[(0,x.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,x.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,x.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,x.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,x.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,x.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,x.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,x.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,x.jsx)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,x.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,x.jsx)(l.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,x.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,x.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,x.jsxs)(l.Card,{children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:e.label}),(0,x.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,x.jsxs)(l.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",j.toLowerCase()]})]})},e.o))]})}},1176,[812,1177,17,385,85,409,777,876,851,863,804,1178,1057,1035,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}),Object.defineProperty(_e,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1178,[17,385,85,777,804,805,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=_,_e.DayBar=function({app:e,today:t}){const a=_(e,t),o=j(e=>e.set),l=a??t,[n,u]=k[e],y=(0,D.useDateCalendar)();return(0,d.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,A.jsxs)(r.default,{testID:"day-bar",style:{gap:8},children:[(0,A.jsx)(s.DaySwitch,{day:l,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day",onPickDate:y.openCal}),a?(0,A.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null,(0,A.jsx)(D.AppDateCalendar,{visible:y.calOpen,today:t,day:l,onDay:t=>o(e,t),onClose:y.closeCal,back:-n,ahead:u,idPrefix:"day-cal"})]})},_e.DayView=function({rid:e,day:s,today:d,app:l}){const n=(0,u.useRestaurant)(e),D=(0,u.useBookings)(e),j=(0,u.useEvents)(e),k=(0,f.parseYmd)(s),_=se.date===s),w=(0,p.regularEventsOf)(n).filter(e=>(0,p.occursOn)(e,s)),T=D.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===l;return(0,A.jsxs)(r.default,{testID:"day-view",style:{gap:12},children:[(0,A.jsxs)(c.Card,{children:[(0,A.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,f.niceDate)(k),$?` \xb7 ${$.name} hours`:'']}),(0,A.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,A.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${C(B[0])}\u2013${C(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${C(v.time)} (${v.reason})`:'']}),w.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${C(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),O.map(e=>(0,A.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,A.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,A.jsx)(a.CoversToday,{rid:e,day:s}),(0,A.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,A.jsxs)(r.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,A.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,A.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,A.jsx)(m.BookingNeeds,{b:s}),'display'!==l&&!_&&['confirmed','pending'].includes(s.status)?(0,A.jsx)(r.default,{style:{flexDirection:'row'},children:(0,A.jsx)(x.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,A.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),f=_r(_d[12]),b=_r(_d[13]),D=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),A=_r(_d[17]);const j=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),k={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},C=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function _(e,t){const s=j(t=>t.day[e]);return s&&s!==t?s:null}},1179,[843,1054,1072,1089,17,85,831,777,858,1055,862,861,863,804,1051,1078,1180,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1180,[17,777,858,1181,8]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1181,[362]); +__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,"payFor",{enumerable:!0,get:function(){return k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,M=(0,f.tipsPeriod)(w,S.start,1),v=(0,f.wagePeriod)(w,D.start,1),B=e=>{l({...a,...e}),x(null)};return(0,$.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,$.jsx)(h.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===d?(0,$.jsx)(h.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,$.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,$.jsx)(h.Chip,{label:R[e],selected:a.tipsFrequency===e,onPress:()=>B({tipsFrequency:e})},e))}),(0,$.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,$.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,$.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,$.jsxs)(h.Row,{children:[(0,$.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>B({tipsEndsDaysBefore:e})}),(0,$.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,$.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,$.jsxs)(h.Card,{children:[(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,$.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>B({wagePayDay:e})})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,$.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>B({wageCutoffDay:e})})]}),(0,$.jsxs)(h.Muted,{children:["Period runs the ",z(a.wageCutoffDay)," to the ",z(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,$.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,$.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,$.jsx)(h.Chip,{label:I[e],selected:(a.weekendRule??'none')===e,onPress:()=>B({weekendRule:e})},e))})]}),(0,$.jsx)(T.SectionHead,{title:"Preview"}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(H,{label:"Next tips payday",day:S.payday,period:S}),(0,$.jsx)(H,{label:"Then",day:M.payday,period:M}),(0,$.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,$.jsx)(H,{label:"Next payday",day:D.payday,period:D}),(0,$.jsx)(H,{label:"Then",day:v.payday,period:v})]}),(0,$.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,$.jsx)(h.Banner,{kind:"success",title:y}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=A,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return Y}}),_e.summaryTable=G,_e.detailTable=U,_e.copyText=_,_e.periodOptions=q,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:v}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:v,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:H}=(0,k.useVenuePay)(s),O=(0,y.useOwner)(e=>e.staff),L=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),F=(0,P.useHourly)(),V=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,$.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,$.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,$.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>q(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>A(ye,O,L,r,F),[ye.key,O,L,F,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage(v)?(0,$.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===H?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,$.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,$.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,$.jsx)(J,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,$.jsx)(h.Card,{highlight:b.colours.gold,children:(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,$.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,$.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,$.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,$.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,$.jsx)(M.HoursExport,{}),B?(0,$.jsx)(i.default,{style:{alignItems:'center'},children:(0,$.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,$.jsx)(h.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await _(E(G(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,Y(G(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,Y(U(ge))),Te('CSV downloaded (one line per shift).')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=G(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,$.jsx)(h.Banner,{kind:"success",title:he}):null,V?(0,$.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,$.jsx)(u.HoursSummaryCard,{name:N(e.person),role:W(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,$.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${N(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"hours-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:K[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,$.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${N(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,$.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,$.jsxs)(i.default,{style:{width:K[0]},children:[(0,$.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",N(e.person)]}),(0,$.jsx)(h.Muted,{children:W(e.person)})]}),(0,$.jsx)(h.T,{size:14,style:{width:K[1]},children:e.shifts}),(0,$.jsx)(h.T,{size:14,weight:"semibold",style:{width:K[2]},children:(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:K[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,$.jsx)(h.T,{size:14,style:{width:K[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:K[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,$.jsxs)(h.T,{size:14,weight:"semibold",style:{width:K[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,$.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:K[0]},children:["Total (",ge.length,")"]}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[1]},children:me.s}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:K[2]},children:(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:K[3]},children:(0,l.durText)(me.p)}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,$.jsx)(h.T,{size:14,style:{width:K[5]},children:" "}),(0,$.jsx)(h.T,{size:14,weight:"bold",style:{width:K[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,$.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,$.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,$.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,$.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,$.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,$.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,M]=(0,n.useState)(0),v=(0,f.tipsPeriod)(u,S.period.start,D),[R,I]=(0,n.useState)(''),[z,H]=(0,n.useState)({}),[O,F]=(0,n.useState)(null),V=(0,n.useMemo)(()=>A(v,p,T,a,{}),[v.key,p,T]),G=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>z[e.id]??G(e),q=V.filter(e=>e.confirmed>0||e.pending>0),J=Math.round(100*((0,B.parseMoneyInput)(R)??NaN)),K=Number.isFinite(J)&&J>0&&J<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(R),Q=q.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:X}=(0,w.allocate)(K?J:0,Q.map(e=>e.confirmed)),Z={};Q.forEach((e,s)=>{Z[e.person.id]=X[s]});const ee=Q.reduce((e,s)=>e+s.confirmed,0),se=Object.values(Z).reduce((e,s)=>e+s,0),te=q.filter(e=>e.pending>0&&!U(e.person)),oe=te.reduce((e,s)=>e+s.pending,0),ne=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...q.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[N(e.person),W(e.person),(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&ee?(e.confirmed/ee*100).toFixed(2):'0.00',s?L(Z[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)(v.start),(0,f.ukDate)(v.end),v.payday?(0,f.ukDate)(v.payday):'',(0,f.decH)(ee),(0,f.hMm)(ee),ee?'100.00':'0.00',L(se)]],re=e=>{F(e),setTimeout(()=>F(null),6e3)};return(0,$.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,$.jsx)(h.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===c?(0,$.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,$.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>M(D-1)}),(0,$.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)(v.start,v.end)}),(0,$.jsxs)(h.Muted,{children:[(0,f.ukDate)(v.start)," to ",(0,f.ukDate)(v.end)," \xb7 ",v.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)(v.payday)]}),0===D?(0,$.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>M(D+1)})]}),(0,$.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,$.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,$.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,$.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,$.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:R,onChangeText:e=>I((0,B.sanitiseMoneyTyping)(e)),placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),R&&!K?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,$.jsx)(h.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),te.length?(0,$.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,$.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,$.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(oe)," not approved yet"]}),(0,$.jsxs)(h.T,{size:14,children:[te.map(e=>`${N(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):q.length?(0,$.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,$.jsx)(o.WideTable,{children:(0,$.jsxs)(i.default,{testID:"tips-table",children:[(0,$.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,$.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),q.map(e=>{const s=U(e.person),t=Z[e.person.id]??0;return(0,$.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,$.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${N(e.person)}`,onPress:()=>H({...z,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,$.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,$.jsxs)(i.default,{style:{width:150},children:[(0,$.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:N(e.person)}),(0,$.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':W(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,$.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,$.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&ee?`${(e.confirmed/ee*100).toFixed(1)}%`:'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,$.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,$.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",Q.length," people)"]}),(0,$.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(ee)," h"]}),(0,$.jsx)(h.T,{size:14,style:{width:64},children:ee?'100%':'\u2013'}),(0,$.jsx)(h.T,{size:15,weight:"bold",colour:K&&se===J?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(se)})]})]})}),q.length?null:(0,$.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),K&&ee?(0,$.jsxs)(h.Muted,{children:["Check: ",Q.length," shares add up to ",(0,x.gbp)(se)," of ",(0,x.gbp)(J)," ",se===J?'\u2713':'',". \xa3",(J/100/(ee/60)).toFixed(4)," per confirmed hour."]}):null,(0,$.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,$.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!K,onPress:async()=>{const e=await _(E(ne()));re(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!K,onPress:()=>{(0,j.downloadText)(`tips-${v.start}-to-${v.end}.csv`,Y(ne())),re('CSV downloaded.')}}),(0,$.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!K,onPress:()=>{const e=ne();(0,j.printTable)(`Tips ${(0,f.rangeText)(v.start,v.end)} (paid ${(0,f.dayMonth)(v.payday)})`,`Total ${(0,x.gbp)(J)} shared by confirmed hours${te.length?` \xb7 WARNING ${(0,f.decH)(oe)} h not signed off`:''}`,e[0],e.slice(1))}})]}),O?(0,$.jsx)(h.Banner,{kind:"success",title:O}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,$.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,$.jsx)(r.CardHeading,{right:'none'===n?(0,$.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next tips payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:["Next payday: ",(0,$.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,$.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,$.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,$.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,$.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,$.jsx)(h.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?A(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,$.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,$.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,$.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,$.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,$.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,$.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,$.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),M=_r(_d[26]),v=_r(_d[27]),B=_r(_d[28]),$=_r(_d[29]);const R={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},I={none:'Keep the date',before:'Friday before',after:'Monday after'};const z=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function H({label:e,day:s,period:t}){return(0,$.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,$.jsxs)(h.T,{children:[e,": ",(0,$.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,$.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const O=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function A(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:O(e.in),outT:O(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),a=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const W=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,N=e=>e.name.replace(' (example)',''),L=e=>null==e?'':(e/100).toFixed(2),F=e=>e.replace(/[\t\r\n]+/g,' '),V=e=>(0,v.csvCell)(e),E=e=>e.map(e=>e.map(F).join('\t')).join('\n'),Y=e=>e.map(e=>e.map(V).join(',')).join('\r\n');function G(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[N(e.person),W(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[L(e.rate),L(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',L(d.g)]:[]]]}function U(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[N(e.person),W(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function _(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function q(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function J({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,$.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,$.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,$.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,$.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const K=[150,54,100,90,48,62,70]},1182,[812,1033,1177,17,1183,219,385,409,85,1185,1186,1187,777,816,876,851,1034,804,889,1193,1178,1057,1035,1188,856,1189,1194,991,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.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(t.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:t="action-grid"}){const l=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),t=e(_r(d[1])),o=e(_r(d[2])),l=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},1183,[17,385,85,1184,804,777,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'cashup'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"10",width:"18",height:"11",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 14h18M8 10V7h8v3M12 17.5v.2",...n})]}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,e.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1184,[17,780,8]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1185,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(o.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(n.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(n.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(n.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(n.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(n.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(o.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(n.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(n.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(n.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(n.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(n.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(o.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(n.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(n.Muted,{center:!0,children:t}):null,(0,h.jsxs)(n.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(n.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(o.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(n.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(n.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(n.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},Object.defineProperty(_e,"REASON_SHORT",{enumerable:!0,get:function(){return y}}),_e.RemoveShiftSheet=function({a:e,who:s,onClose:o}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(n.Sheet,{visible:!0,onClose:o,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(n.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),p?null:(0,h.jsx)(n.T,{size:15,center:!0,colour:c.colours.amber,testID:"remove-shift-reason-short",children:y}),(0,h.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(n.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),o()},style:{minHeight:56}}),(0,h.jsx)(n.Button,{kind:"secondary",label:"Keep it",onPress:o,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});const y='The reason is too short. Type at least 3 letters, for example \u201cForgot to clock out\u201d.'},1186,[17,85,777,812,876,851,1185,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}),Object.defineProperty(_e,"REASONS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=O,_e.notesFor=T,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=P,_e.TimeEdit=q,_e.OverrideSheet=H,_e.outstandingDays=N,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:N(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,y.jsx)(z,{}):(0,y.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]);const w=['Forgot to clock in','Forgot to clock out','Wrong time'],I=[0,15,20,30,45,60],S=e=>(e??'').replace(' (example)',''),v=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},C=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},$=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},M=(e,t)=>e===t?'Today':e===$(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function O(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=v(e.in)-Math.round(60*t.start),s=e.out?v(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&v(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function T(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const R=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},A={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function P({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,y.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,y.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,y.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:13,weight:"semibold",children:[A[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,y.jsxs)(l.Muted,{children:[S(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,y.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function q({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,y.jsxs)(a.default,{style:{gap:6},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,y.jsx)(l.Muted,{children:"next day"}):null]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,y.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??C(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function H({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:j,now:k,role:C}=(0,h.useCtx)(3e4),[$,M]=(0,s.useState)(!1),O=!!e&&(0,m.canSeeHoursEdit)({role:C,isCar:p.IS_CAR}),T=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),A=(0,r.useOwner)(e=>e.shifts),H=(0,r.shiftOf)(A,t,n),N=o?.suggestedIn?v(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):H?Math.round(60*H.start):720,z=o?.suggestedOut??e?.out,F=z?(E=z,Math.round((new Date(E).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:H?Math.round(60*H.end):N+480;var E;const[_,L]=(0,s.useState)(N),[Y,W]=(0,s.useState)(F),[V,G]=(0,s.useState)(e?.breakMins??(H&&H.end-H.start>6?30:0)),[K,U]=(0,s.useState)(o?'out'===o.kind?w[1]:w[0]:e?e.in&&!e.out?w[1]:null:w[0]),[Z,J]=(0,s.useState)(''),[Q,X]=(0,s.useState)(null),ee=[K,Z.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),te=null!=Y?Y-_:0,ne=e?(0,h.paidMins)(e,k):null,se=null!=Y?Math.max(0,te-V):null,oe=e&&'confirmed'===(0,r.attStatus)(e),ae=null!=Y&&Y<=_?'Clock-out must be after clock-in.':te>1200?'A shift can\u2019t be longer than 20 hours.':null!=Y&&V>=te?'The break is longer than the shift.':null,le=e?.in&&!o&&_===N?e.in:D(n,_),ie=null==Y?void 0:e?.out&&!o&&Y===F?e.out:D(n,Y),re=!e||le!==e.in||(ie??'')!==(e.out??'')||(e.breakMins??0)!==V;return(0,y.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${S(T)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,y.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,y.jsx)(l.Badge,{kind:B(e),label:R(e)}):(0,y.jsx)(l.Badge,{kind:"red",label:"No clock record"}),H?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(H.start)}\u2013${(0,h.fmtH)(H.end)}`}):(0,y.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,y.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,y.jsxs)(l.Banner,{kind:"info",title:`${S(T)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,y.jsx)(q,{label:"Clock in",mins:_,onChange:L,testID:"ov-in"}),null!=Y?(0,y.jsx)(q,{label:"Clock out",mins:Y,onChange:W,testID:"ov-out"}):(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.Muted,{children:"No clock-out yet."}),(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>W(H?Math.round(60*H.end):Math.min(_+480,60*k.getHours()+k.getMinutes()>_?60*k.getHours()+k.getMinutes():_+480))})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,y.jsxs)(l.Row,{wrap:!0,gap:6,children:[I.map(e=>(0,y.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:V===e,onPress:()=>G(e)},e)),(0,y.jsx)(l.Stepper,{value:V,min:0,max:240,onChange:G,label:"break minutes"})]}),(0,y.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:w.map(e=>(0,y.jsx)(l.Chip,{label:e,selected:K===e,onPress:()=>U(K===e?null:e)},e))}),(0,y.jsx)(l.Field,{label:K?'Add detail (optional)':'Or type a reason',value:Z,onChangeText:J,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,y.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(l.T,{children:"Paid hours"}),(0,y.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=se?(0,h.hmDur)(se):'still on shift'})]}),ne&&e?.out?(0,y.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(ne.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",ne.brk,"m break)"]}):null,oe?(0,y.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),ae?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:ae}):null,Q?(0,y.jsx)(l.T,{size:13,colour:c.colours.red,children:Q}):null,!ae&&re&&ee.trim().length<3?(0,y.jsx)(l.T,{size:15,center:!0,colour:c.colours.amber,testID:"ov-reason-short",children:ee.trim()?b.REASON_SHORT:'Pick a reason above or type one (at least 3 letters) to save.'}):null,(0,y.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!ae||!re||ee.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:le,out:ie,breakMins:V,reason:ee.slice(0,200),by:d,byId:j,now:k.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,k.toISOString()),i()):X('Couldn\u2019t save: check the times and the reason.')}}),O?(0,y.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,y.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>M(!0),style:{minHeight:48,minWidth:160}})}):null,e&&$?(0,y.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>M(!1),onDeleted:i}):null,e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,y.jsx)(P,{a:e})]}):null]})}function N(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function z(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),b=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),I=(0,r.useOwner)(e=>e.leave),v=(0,s.useMemo)(()=>N(x,t),[x,t]),[D,C]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[q,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===D&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(b,n.staffId,D);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:O(n,s,e,t,w)}});b.filter(e=>e.date===D&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(I,n.staffId,D);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(D60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,b,w,I,D,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===D),Y=w.filter(e=>'open'===e.status&&e.date!==D),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...v.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=$(t,-e);K.includes(n)||K.push(n)}const U=A?(0,j.pastWeekDays)(D,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,y.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[v.filter(e=>e.date!==D).length?(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>C(v.filter(e=>e.date!==D)[v.filter(e=>e.date!==D).length-1].date),children:(0,y.jsx)(l.Banner,{kind:"warn",title:`${v.filter(e=>e.date!==D).length} earlier ${1===v.filter(e=>e.date!==D).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,y.jsx)(k.HoursDayPicker,{testID:"so-pick",date:D,today:t,custom:A,onDate:e=>{C(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{C(t),P(!1),E(null)}}),(0,y.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=v.find(t=>t.date===e);return(0,y.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,j.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:M(e,t),sub:n?`${n.n} to sign off`:void 0,selected:D===e,onPress:()=>{C(e),E(null)}},e)})}),(0,y.jsx)(l.Card,{children:(0,y.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[M(D,t),D===t||D===$(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(D))}`:'']}),(0,y.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,y.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,y.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,y.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,y.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,y.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,y.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,y.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsxs)(l.T,{weight:"semibold",children:[S(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,y.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,y.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,y.jsxs)(l.Row,{gap:6,children:[(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,y.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,y.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,y.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,y.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,y.jsxs)(l.Row,{gap:10,children:[(0,y.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,y.jsxs)(a.default,{style:{flex:1},children:[(0,y.jsx)(l.T,{weight:"semibold",children:S(n?.name)}),(0,y.jsx)(l.Muted,{children:[n?.job,...T(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,y.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,y.jsx)(l.Badge,{kind:B(s),label:R(s)}):t.leave?(0,y.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,y.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,y.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,y.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,y.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,y.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,y.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,y.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,y.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,y.jsxs)(l.Muted,{children:["Adjusted by ",S(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,y.jsxs)(l.Muted,{children:["Confirmed by ",S(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,y.jsxs)(l.Row,{gap:8,children:[(0,y.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${S(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,y.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${S(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,y.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,y.jsx)(l.Card,{children:(0,y.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,y.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,y.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),q?(0,y.jsx)(H,{a:q.a,staffId:q.staffId,date:q.request?.date??q.a?.date??D,request:q.request,onClose:()=>z(null)}):null]})}},1187,[812,1185,17,385,85,777,884,876,1071,863,804,1178,1057,1188,856,1189,1186,1190,1192,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1188,[1033,1049,1064]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1189,[17,85,777,876,1008,1033,1064,1062,1188,804,856,1187,1050,1057,8]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1190,[1034,1191]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1191,[1034,1185]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,w]=(0,t.useState)(''),[C,I]=(0,t.useState)(!1),[v,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,c.rangeSpeech)(e,l))},L=(0,c.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,c.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,c.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);w(t);const s=(0,c.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:v?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:C?'Close calendar':'Calendar',accessibilityLabel:(C?'Close':'Open')+" the calendar to pick a day",onPress:()=>I(!0),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),(0,y.jsx)(b.AppDateCalendar,{visible:C,today:l,day:e,idPrefix:`${p}-calendar`,back:3650,ahead:0,onClose:()=>I(!1),onDay:e=>{const t=e??l;if(I(!1),t>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}w((0,d.ukDate)(t)),W(t)}}),v?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:v})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,c.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{w(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1192,[17,85,777,812,1033,1034,1190,1097,804,1051,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,"category",{enumerable:!0,get:function(){return I}}),_e.allocate=B,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:M,role:v,meId:F,me:R}=(0,x.useCtx)(6e4),N=(0,u.useOwner)(e=>e.staff),A=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),E=(0,u.useOwner)(e=>e.shifts),z=(0,u.useOwner)(e=>e.tronc),_=(0,u.useOwner)(e=>e.troncCash),V=(0,u.useOwner)(e=>e.troncHistory),U=(0,u.useOwner)(e=>e.troncLog),q=(0,c.useOrders)(C),H=(0,j.useVenuePay)(C).pay,[W,Y]=(0,i.useState)(-1),[K,G]=(0,i.useState)(''),[Q,J]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[ee,te]=(0,i.useState)(z.text),[se,oe]=(0,i.useState)(null),ie='staff'!==v,ne='owner'===v,{s:re,e:le,key:ae}=(0,j.venueRange)(H,'tips',W,S),de=`${(0,h.niceDate)(re)} \u2013 ${(0,h.niceDate)(le)} ${le.getFullYear()}`,ce=V.find(e=>e.key===ae),ue=e=>u.useOwner.getState().setOwner({tronc:{...z,...e}}),pe=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),he=Math.round((le.getTime()-re.getTime())/864e5)+1,me=(0,i.useMemo)(()=>{let e=q.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(re)&&e.createdAt.slice(0,10)<=(0,h.ymd)(le)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!pe)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[ae,q.length,pe]),fe=(0,T.useCashUp)(e=>e.cashUps),ye=Math.round(100*(0,k.cashUpTipsBetween)(fe,C,(0,h.ymd)(re),(0,h.ymd)(le))),ge=_[ae]??0,xe=ce?ce.pot:me+ye+ge,je=(0,i.useMemo)(()=>{const e={};for(let t=0;tM)break;const o=(0,h.ymd)(s);N.forEach(t=>{const s=A.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[ae,A.length,E.length,N.length]),be=N.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&z.includeManagers||'owner'===e.role&&z.includeOwner)),we=(0,i.useMemo)(()=>{if(ce)return ce.rows;const e=be.map(e=>{const t=(je[e.id]?.paid??0)/60,s=z.points[I(e)]??1;return'hours'===z.method?t:'points'===z.method?t*s:'equal'===z.method?t>0?1:0:z.custom[e.id]??0}),{amounts:t}=B(xe,e),s=e.reduce((e,t)=>e+t,0);return be.map((o,i)=>({staffId:o.id,hours:(je[o.id]?.paid??0)/60,points:z.points[I(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[ce,be.map(e=>e.id).join(),je,z,xe]),Te=we.reduce((e,t)=>e+t.amount,0),Ce=ce?0:(()=>{const e=we.map(e=>e.pct);return B(xe,e).remainder})(),Se=Object.entries(z.custom).filter(([e])=>be.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),ke='custom'===z.method&&Math.abs(Se-100)>.01,Me=new Date(le.getFullYear(),le.getMonth()+2,0),ve=[...V].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==V.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),$e=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(we.map(e=>{const t=N.find(t=>t.id===e.staffId);return`${D(t.name)},${I(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(Te/100).toFixed(2)}`]);return ie?(0,$.jsxs)(l.default,{style:{gap:10},children:[(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,$.jsx)(d.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>Y(W-1)}),(0,$.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,$.jsx)(d.T,{weight:"semibold",children:de}),ce?(0,$.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${ce.lockedAt}`}):W>=0?(0,$.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,$.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:W>=0,onPress:()=>Y(W+1)})]}),(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Card tips on orders"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.card:me)})]}),(0,$.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cashUps??0:ye)})]})}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:"Other cash tips"}),(0,$.jsx)(d.T,{children:(0,p.gbp)(ce?ce.cash:ge)})]}),ce?null:(0,$.jsxs)(d.Row,{gap:6,children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",inputMode:"decimal",value:K,onChangeText:e=>G((0,P.sanitiseMoneyTyping)(e)),style:[d.styles.input,{flex:1}]}),(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(K)>=0)||''===K.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{..._,[ae]:Math.round(100*Number(K))}}),G('')}})]}),(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,$.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(xe)})]}),(0,$.jsx)(d.Muted,{children:pe?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),ce?(0,$.jsxs)(d.Muted,{children:["Locked with method: ",O[ce.method],"."]}):(0,$.jsxs)(d.Card,{children:[(0,$.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,$.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys(O).map(e=>(0,$.jsx)(d.Chip,{label:O[e],selected:z.method===e,onPress:()=>ne&&ue({method:e})},e))}),ne?null:(0,$.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===z.method?Object.entries(z.points).map(([e,t])=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{children:e}),(0,$.jsx)(d.Row,{gap:6,children:(0,$.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ne&&ue({points:{...z.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===z.method?(0,$.jsxs)($.Fragment,{children:[be.map(e=>(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{style:{flex:1},children:D(e.name)}),(0,$.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(z.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ue({custom:{...z.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ue({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,$.jsxs)(d.T,{size:13,colour:ke?m.colours.red:m.colours.ok,children:["Total ",Se.toFixed(1),"%",ke?' (must be 100%)':' \u2713']})]}):null,(0,$.jsx)(d.Toggle,{label:"Include managers",value:z.includeManagers,onChange:e=>ne&&ue({includeManagers:e})}),(0,$.jsx)(d.Toggle,{label:"Include owner",value:z.includeOwner,onChange:e=>ne&&ue({includeOwner:e})}),z.includeOwner?(0,$.jsx)(d.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),n?(0,$.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.T,{center:!0,weight:"semibold",children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,$.jsxs)(d.T,{center:!0,children:["Points: ",'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013']}),(0,$.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,$.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,$.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(Te)]})]}):(0,$.jsx)(r.default,{horizontal:!0,children:(0,$.jsxs)(l.default,{children:[(0,$.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,$.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),we.map(e=>{const t=N.find(t=>t.id===e.staffId);return(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,$.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[D(t?.name),je[e.staffId]?.est&&!ce?'*':'']}),(0,$.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,$.jsx)(d.T,{size:13,style:{width:54},children:'points'===z.method||'points'===ce?.method?e.points.toFixed(1):'\u2013'}),(0,$.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,$.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,$.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,$.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,$.jsx)(d.T,{size:13,weight:"bold",colour:Te===xe?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(Te)})]})]})}),(0,$.jsxs)(d.Muted,{children:[Te===xe?`\u2713 Total equals the pot (${(0,p.gbp)(xe)}).`:'\u2717 Total does not equal the pot.',Ce?` Rounding: ${Ce}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ce?null:(0,$.jsx)(d.Button,{label:"Approve & lock period",disabled:!ne||W>=0||ke||Te!==xe||xe<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${ae}`,key:ae,label:de,end:(0,h.ymd)(le),pot:xe,card:me,cash:ge,cashUps:ye,method:z.method,rows:we,lockedAt:e,by:R};u.useOwner.getState().setOwner({troncHistory:[t,...V],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${R} approved & locked tips for ${de}: ${(0,p.gbp)(xe)} split ${O[z.method].toLowerCase()} between ${we.filter(e=>e.amount>0).length} staff`},...U]})}}),!ce&&W>=0?(0,$.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ne||ce?null:(0,$.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,$.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>J(!0)}),ce?(0,$.jsx)(d.Button,{small:!0,kind:"secondary",label:ce.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ce.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${de} approved: ${(0,p.gbp)(ce.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:V.map(e=>e.id===ce.id?{...e,shared:(0,h.niceDate)(S)}:e)}),oe('Posted to All staff chat.')}}):null]}),se?(0,$.jsx)(d.Banner,{kind:"info",title:se}):null,(0,$.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,$.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(xe)} = allocated ${(0,p.gbp)(Te)}`],[z.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(Me)} ${Me.getFullYear()}`],[!0,'Tip records kept for 3 years',`${V.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${U.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,$.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,$.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,$.jsxs)(l.default,{style:{flex:1},children:[(0,$.jsx)(d.T,{size:14,children:t}),(0,$.jsx)(d.Muted,{children:s})]})]},String(t))),(0,$.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{te(z.text),Z(!0)}})]}),(0,$.jsx)(y.SectionHead,{title:"Tip history & audit log"}),V.map(e=>(0,$.jsxs)(d.Card,{children:[(0,$.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(d.T,{weight:"semibold",children:e.label}),(0,$.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,$.jsxs)(d.Muted,{children:[O[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),U.map(e=>(0,$.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),V.length||U.length?null:(0,$.jsx)(d.Muted,{children:"No approved periods yet."}),(0,$.jsxs)(d.Sheet,{visible:Q,onClose:()=>J(!1),title:"Tips summary export",children:[(0,$.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,$.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:$e.map((e,t)=>(0,$.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,$.jsxs)(d.Muted,{children:[de," \xb7 ",O[ce?.method??z.method]]})]}),(0,$.jsxs)(d.Sheet,{visible:X,onClose:()=>Z(!1),title:"Tipping policy",children:[(0,$.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ne,value:ee,onChangeText:te,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ne?(0,$.jsx)(d.Button,{label:"Save policy",onPress:()=>{ue({text:ee}),Z(!1)}}):null,(0,$.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,$.jsx)(L,{})},_e.useStaffTips=A,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=A(e,t);(0,i.useEffect)(()=>{if(!o.showToday||R()||v.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=A(e,t),r=`Tip pot this period, ${F(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${F(i)}`;return(0,$.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,$.jsx)(E,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,$.jsx)(E,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=L;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),M=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),$=_r(_d[27]);const O={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},I=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',D=e=>(e??'').replace(' (example)','');function B(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const F=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function R(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const N={pot:186.4,today:48.5};function A(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,M.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||v.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),R()?{pot:N.pot,today:N.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function E({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${F(s)}`;return(0,$.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,$.jsx)(d.Muted,{center:!0,children:o}):(0,$.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:F(s)})]})}function L(e={}){const t=(0,x.useCtx)(6e4),s=A(t.rid,t.today);return(0,$.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,$.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,$.jsx)(E,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,$.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,$.jsx)(E,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1193,[813,812,822,17,385,278,85,409,777,858,876,851,863,804,1161,1178,1057,1035,1139,899,1008,1032,839,1049,1034,880,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.MonthCalendar=function({value:e,onPick:t,testID:n,label:a}){const d=e??(0,i.ymd)(new Date),[c,u]=(0,s.useState)({y:Number(d.slice(0,4)),m:Number(d.slice(5,7))-1}),x=(new Date(c.y,c.m,1).getDay()+6)%7,y=new Date(c.y,c.m+1,0).getDate(),b=[...Array(x).fill(null),...Array.from({length:y},(e,t)=>t+1)];for(;b.length%7;)b.push(null);const f=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,j.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>f(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,j.jsx)(o.T,{weight:"semibold",center:!0,children:`${w[c.m]} ${c.y}`}),(0,j.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>f(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,j.jsx)(r.default,{style:{flexDirection:'row'},children:$.map(e=>(0,j.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:b.length/7},(s,d)=>(0,j.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:b.slice(7*d,7*d+7).map((s,d)=>{if(!s)return(0,j.jsx)(r.default,{style:{flex:1,height:40}},d);const u=(0,i.ymd)(new Date(c.y,c.m,s)),x=u===e;return(0,j.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${w[c.m]} ${c.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,j.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},d)})},d))]})},_e.HoursExport=function(){const{role:e}=(0,y.useCtx)(6e4);return a.CAN.manage(e)?(0,j.jsx)(C,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),y=_r(_d[13]),b=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),p=_r(_d[17]),j=_r(_d[18]);const D=e=>(0,d.ukDate)(e),w=['January','February','March','April','May','June','July','August','September','October','November','December'],$=['Mo','Tu','We','Th','Fr','Sa','Su'];function T({label:e,text:l,setText:a,testID:c}){const[x,f]=(0,s.useState)(!1),m=(0,i.parseDmy)(l),{today:p}=(0,y.useCtx)(6e4);return(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,j.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,j.jsx)(n.TextInput,{testID:c,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!m?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,j.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${c}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>f(!0)}),(0,j.jsx)(b.AppDateCalendar,{visible:x,today:p,day:m??p,idPrefix:`${c}-calendar`,back:3650,ahead:0,onClose:()=>f(!1),onDay:t=>{const s=t??p;a(D(s)),f(!1),(0,u.announce)(`${e} ${(0,d.ukDate)(s)}`)}})]})}function C(){const{rid:e,today:t,now:l,r:n}=(0,y.useCtx)(6e4),{pay:b}=(0,p.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),C=(0,y.useHourly)(),k=(0,i.weekOf)(t),[I]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(D(I?.start??k.start)),[R,M]=(0,s.useState)(D(I?.end??k.end));(0,s.useEffect)(()=>{if(!I)return;(0,u.announce)((0,m.presetNote)(I.start,I.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[I]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,d.wagePeriod)(b,t),A=[{id:'this',label:'This week',...k},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],H=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,C).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,C,Math.floor(l.getTime()/6e4)]),Y=H.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,j.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,j.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,j.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),I?(0,j.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(I.start,I.end)})}):null,(0,j.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,j.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(D(e.start)),M(D(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,d.ukDate)(e.start)} to ${(0,d.ukDate)(e.end)}`)}},e.id))}),(0,j.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,j.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,j.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,j.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,j.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,j.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${H.length} ${1===H.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,d.decH)(N)} hours)`}),_?(0,j.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,j.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,H,l));B(e?`Copied hours for ${H.length} ${1===H.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,j.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,c.buildXlsx)((0,i.hoursSheets)(n.name,z,E,H,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:c.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,d.ukDate)(z)} to ${(0,d.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,j.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,j.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,j.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1194,[1033,17,385,85,777,812,876,1191,1034,1195,1097,804,1182,1057,1051,1185,1190,1035,8]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1195,[]); +__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.useWeekSales=ne,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return oe}}),_e.rotaGrid=le,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:a}=(0,O.useCtx)(6e4),l=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),i=(0,s.useOwner)(e=>e.shifts),d=(0,O.useHourly)(),c=(0,s.useOwner)(e=>e.availability),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),b=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),[j,S]=(0,r.useState)(0),P=(0,_.useDateCalendar)(),[B,R]=(0,r.useState)(null),[A,z]=(0,r.useState)(null),[L,N]=(0,r.useState)(null),[Y,E]=(0,r.useState)('week'),[q,J]=(0,r.useState)(!1),Z=(0,O.useSignedIn)()?.name??'',de='staff'!==n,ce=(0,D.addMins)(se(t),7*j*1440);ce.setHours(0,0,0,0);const ue=ne(ce),he=ue.sales,fe='none'===ue.mode,me=(0,W.weekSalesCardCopy)(ue),ge=Array.from({length:7},(e,t)=>{const s=new Date(ce);return s.setDate(ce.getDate()+t),(0,D.ymd)(s)}),pe=(0,s.visibleShifts)(i,de).filter(e=>e.date>=ge[0]&&e.date<=ge[6]),xe=(()=>{const e=new Date(ce);return e.setDate(e.getDate()-7),(0,D.ymd)(e)})(),be=pe.filter(e=>!e.published||e.changed).length,je=i.filter(e=>e.date>=xe&&e.date!!(0,s.leaveOn)(h,e,t),ke=ge.map(e=>(0,p.workingShifts)(pe,h).filter(t=>t.date===e).reduce((e,t)=>{return e+(ee(s=t)-te(ee(s)))*(d[s.staffId]??0);var s},0)),ye=ke.reduce((e,t)=>e+t,0),Ie=he.reduce((e,t)=>e+t,0),Se=(e,t)=>t?Math.round(e/t*100):0,Ce=de?l:l.filter(e=>e.id===a),De=(0,o.useNarrow)(),ve=Math.max(0,ge.indexOf((0,D.ymd)(t))),[Te,$e]=(0,r.useState)(null),Oe=Te??ve,Me=(e,t)=>!De||t===Oe,[Pe,Be]=(0,r.useState)(0),Re=le(Pe,De?1:7),Ae=Re.cell,ze=Re.name;return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Week",selected:'week'===Y,onPress:()=>E('week')}),(0,G.jsx)(m.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+h.filter(e=>'pending'===e.status).length})`,selected:'requests'===Y,onPress:()=>E('requests')}),(0,G.jsx)(m.Chip,{label:"Availability",selected:'availability'===Y,onPress:()=>E('availability')})]}),'week'===Y?(0,G.jsxs)(G.Fragment,{children:[!de&&a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,G.jsx)(f.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,G.jsx)(m.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,F.timeSheetLabel)(ge[0],ge[6]),onPress:()=>{(0,F.setHoursPreset)(ge[0],ge[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,G.jsxs)(f.default,{testID:"rota-week-nav",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',alignSelf:'center',width:Pe?Math.min(Pe,Re.width):'100%',maxWidth:'100%',gap:8,justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{S(j-1),R(null)},style:{minWidth:96}}),(0,G.jsxs)(f.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,G.jsxs)(m.T,{weight:"semibold",center:!0,children:["Week of ",(0,D.niceDate)(ce)]}),(0,G.jsxs)(m.Muted,{center:!0,children:[0===j?'This week':1===j?'Next week':-1===j?'Last week':j>0?`In ${j} weeks`:-j+" weeks ago",de?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{S(j+1),R(null)},style:{minWidth:96}})]}),(0,G.jsx)(f.default,{style:{alignItems:'center',alignSelf:'center'},children:(0,G.jsx)(m.Button,{small:!0,kind:"ghost",testID:"rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:P.openCal,style:{minWidth:96}})}),(0,G.jsx)(_.AppDateCalendar,{visible:P.calOpen,today:(0,D.ymd)(t),day:(0,D.ymd)(ce),idPrefix:"rota-cal",onClose:P.closeCal,onDay:e=>{S((0,_.weekOffsetOf)(e??(0,D.ymd)(t),(0,D.ymd)(t))),R(null)}}),de?(0,G.jsxs)(m.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,G.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy last week"+(je?` (${je})`:''),disabled:!je,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(xe,ge[0]);R(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,G.jsx)(m.Button,{small:!0,kind:"success",label:be?`Publish ${be} ${1===be?'change':'changes'}`:'Week published',disabled:!be,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ge[0]);R(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),be?(0,G.jsx)(m.Badge,{kind:"amber",label:`${be} unpublished`}):pe.length?(0,G.jsx)(m.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,B?(0,G.jsx)(m.Banner,{kind:"success",title:B}):null,De?(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:O.DAY3.map((e,t)=>K.IS_CAR?(0,G.jsx)(m.Button,{kind:t===Oe?'primary':'secondary',label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,accessibilityLabel:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}${t===Oe?', chosen':''}`,testID:`rota-day-${e.toLowerCase()}`,onPress:()=>$e(t),style:{minHeight:64,minWidth:96}},e):(0,G.jsx)(m.Chip,{label:`${e} ${(0,D.parseYmd)(ge[t]).getDate()}`,selected:t===Oe,onPress:()=>$e(t)},e))}):null,(0,G.jsx)(f.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-Pe)>1&&Be(t)},style:{alignSelf:'stretch'},children:(0,G.jsx)(re,{fits:De||Re.fits,children:(0,G.jsxs)(f.default,{testID:"rota-grid",style:{gap:oe,width:Re.width,alignSelf:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:oe,backgroundColor:v.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:v.colours.hairline,zIndex:5},De||Re.fits?ie:null],children:[(0,G.jsx)(f.default,{style:{width:ze,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:11,weight:"semibold",colour:v.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),O.DAY3.map((e,s)=>(0,G.jsx)(f.default,{testID:"rota-date",style:{width:Ae,alignItems:'center'},children:(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,colour:ge[s]===(0,D.ymd)(t)?v.colours.gold:v.colours.text,children:[e," ",(0,D.parseYmd)(ge[s]).getDate()]})},e)).filter(Me)]}),Ce.map(e=>(0,G.jsxs)(f.default,{testID:"rota-row",style:{flexDirection:'row',gap:oe,alignItems:'center'},children:[(0,G.jsxs)(f.default,{testID:"rota-name",style:{width:ze,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:28}),(0,G.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,G.jsx)(m.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,G.jsx)(m.T,{size:11,colour:v.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),O.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(pe,e.id,ge[n]),o=(c[e.id]??[]).includes(n),l=we(e.id,ge[n]),i=(0,x.rotaCellWorked)(a,b,e.id,ge[n],de),r=!(!de||!i.workedLine&&!i.onShiftNow);return(0,G.jsxs)(u.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name.replace(' (example)','')} ${O.DAY3[n]}, ${i.speech}${(0,U.badgeSpoken)(a?.badge)}${l?', on time off':''}${o?', unavailable':''}`,disabled:!de,onPress:()=>{a?N({staffId:e.id,date:ge[n],shift:a}):z({staffId:e.id,date:ge[n]})},style:({pressed:e})=>({width:Ae,minHeight:K.IS_CAR?64:r?80:52,height:r||(0,U.cleanBadge)(a?.badge)||K.IS_CAR?void 0:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:i.differs?v.colours.amber:a?a.published?v.colours.gold:v.colours.amber:v.colours.border,backgroundColor:e?v.colours.goldTint:a?a.published?'#2b2414':'#241f14':l?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4,paddingVertical:r||(0,U.cleanBadge)(a?.badge)?6:0}),children:[a?(0,G.jsxs)(m.T,{size:Re.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,O.fmtH)(a.start),"\u2013",(0,O.fmtH)(a.end)]}):i.workedLine?null:(0,G.jsx)(m.T,{size:12,center:!0,colour:v.colours.muted,children:l?'Off':o?'Unavail.':de?'Add':'\u2013'}),(0,U.cleanBadge)(a?.badge)?(0,G.jsx)(f.default,{testID:"rota-badge",style:{marginTop:2,borderRadius:8,borderWidth:1,borderColor:v.colours.gold,paddingHorizontal:5,maxWidth:'100%'},children:(0,G.jsx)(m.T,{size:10,weight:"semibold",colour:v.colours.gold,center:!0,numberOfLines:1,children:(0,U.cleanBadge)(a?.badge)})}):null,i.workedLine?(0,G.jsx)(m.T,{testID:"rota-worked",size:10,colour:i.differs?v.colours.amber:v.colours.goldLight,center:!0,children:i.workedLine}):null,i.onShiftNow?(0,G.jsx)(m.T,{testID:"rota-on-shift-now",size:10,colour:v.colours.goldLight,center:!0,children:"On shift now"}):null,i.diffLabel?(0,G.jsx)(m.T,{size:10,colour:v.colours.amber,center:!0,children:i.diffLabel}):null,a&&l?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(h,e.id,ge[n])).toLowerCase()}):a&&o?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.red,children:"unavailable"}):!a||!de||a.published&&!a.changed||i.workedLine||i.onShiftNow?null:(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.amber,children:a.published?'changed':'draft'})]},n)}).filter(Me)]},e.id)),de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe,marginTop:4},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour"})}),ke.map((e,t)=>(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,children:(0,C.gbp)(e).replace('.00','')})},t)).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{testID:"rota-sales-row",style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:'example'===ue.mode?'Sales (ex.)':'Sales'})}),ue.days.map((e,t)=>{const s=e.pence,n=e.kind,a='shut'===n?'shut':'none'!==n&&s?`\xa3${Math.round(s/100)}`:'\u2013',o='shut'===n?`${O.DAY3[t]} shut`:'actual'===n?`${O.DAY3[t]} sales \xa3${Math.round(s/100)} actual`:'forecast'===n?`${O.DAY3[t]} forecast sales \xa3${Math.round(s/100)}`:`${O.DAY3[t]} no sales figure`;return(0,G.jsxs)(f.default,{testID:"rota-sales-cell",accessible:!0,accessibilityLabel:o,style:{width:Ae,alignItems:'center'},children:[(0,G.jsx)(m.T,{size:12,center:!0,colour:'actual'===n?v.colours.text:v.colours.muted,children:a}),'forecast'===n&&s?(0,G.jsx)(m.T,{size:10,center:!0,colour:v.colours.muted,children:"fcst"}):null]},t)}).filter(Me)]}),fe?null:(0,G.jsxs)(f.default,{style:{flexDirection:'row',gap:oe},children:[(0,G.jsx)(f.default,{style:{width:ze},children:(0,G.jsx)(m.Muted,{children:"Labour %"})}),ke.map((e,t)=>{const s=Se(e,he[t]);return(0,G.jsx)(f.default,{style:{width:Ae,alignItems:'center'},children:(0,G.jsx)(m.T,{size:12,center:!0,weight:"semibold",colour:he[t]?s>32?v.colours.red:s>26?v.colours.amber:v.colours.ok:v.colours.muted,children:he[t]?`${s}%`:'\u2013'})},t)}).filter(Me)]})]}):null]})})}),!de&&a?(0,G.jsx)(f.default,{testID:"rota-team-on",children:(0,G.jsx)(m.Card,{children:ge.map((e,t)=>(0,G.jsx)(w.TeamOnDay,{date:e,meId:a,label:(0,D.niceDate)((0,D.parseYmd)(e))},e)).filter(Me)})}):null,de&&fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Labour this week"}),(0,G.jsx)(f.default,{testID:"labour-week-cost",children:(0,G.jsx)(m.T,{weight:"semibold",children:(0,C.gbp)(ye)})})]}),(0,G.jsxs)(m.Muted,{children:[(0,C.gbp)(ye)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,G.jsx)(m.Muted,{children:`Forecasts start once CoverCharge has ${1===ue.weeks?'1 week':`${ue.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),ue.booked?(0,G.jsx)(f.default,{testID:"labour-booked",children:(0,G.jsxs)(m.T,{children:["Booked so far: ",ue.booked," Covers this week"]})}):null]})}):null,de&&!fe?(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:"labour-vs-sales",style:{gap:6},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:me.title}),(0,G.jsxs)(m.Row,{gap:6,children:['example'===ue.mode?(0,G.jsx)(H.ExampleBadge,{}):null,(0,G.jsx)(m.Badge,{kind:Se(ye,Ie)>30?'red':'ok',label:`${Se(ye,Ie)}% this week`})]})]}),(0,G.jsxs)(m.Muted,{testID:"sales-mix-words",children:[(0,C.gbp)(ye)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs ",(0,C.gbp)(Ie)," sales",ue.mixWords?` (${ue.mixWords})`:'',". Target 25\u201330%. ",me.bodyTail]}),(()=>{const e=Se(ke[5],he[5]),t=ue.days[5]?.kind;return e&&e<24&&'forecast'===t?(0,G.jsxs)(m.T,{size:14,colour:v.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]})}):null,de?(0,G.jsx)(m.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>de||e.fromId===a||e.toId===a).map(e=>{const t=i.find(t=>t.id===e.shiftId),n=l.find(t=>t.id===e.fromId),a=l.find(t=>t.id===e.toId);return(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,G.jsxs)(m.Muted,{children:[t?`${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:l.filter(e=>X(n,e)).map(t=>(0,G.jsx)(m.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,G.jsx)(m.Button,{small:!0,label:"Approve",disabled:!e.toId||!X(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(l.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,$.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${O.DAY3[t.day]} ${(0,O.fmtH)(t.start)}\u2013${(0,O.fmtH)(t.end)})`:''}`)}}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),de?null:(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,G.jsx)(m.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,G.jsx)(m.Muted,{testID:"swap-dept-note",children:(0,k.isAnchorageVenue)(y.VENUE_RID)?k.ANCHORAGE_SWAP_NOTE:Q(l.find(e=>e.id===a))?k.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),pe.filter(e=>e.staffId===a).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,G.jsxs)(f.default,{style:{gap:4,paddingVertical:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:14,weight:"medium",children:[O.DAY3[e.day]," ",(0,O.fmtH)(e.start),"\u2013",(0,O.fmtH)(e.end),(0,U.cleanBadge)(e.badge)?` \xb7 ${(0,U.cleanBadge)(e.badge)}`:'']}),t?(0,G.jsx)(m.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,kind:'cover',note:'Can anyone cover?'}),(0,$.autoPost)('all',`Cover needed: ${O.DAY3[e.day]} ${(0,O.fmtH)(e.start)}\u2013${(0,O.fmtH)(e.end)} (${(l.find(e=>e.id===a)?.name??'').replace(' (example)','')})`)}}),l.filter(e=>X(l.find(e=>e.id===a),e)).map(t=>(0,G.jsx)(m.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:a,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),pe.some(e=>e.staffId===a)?null:(0,G.jsx)(m.Muted,{children:"No shifts on the rota this week."})]}),(0,G.jsx)(T.SectionHead,{title:"Holiday & time off"}),de?(0,G.jsx)(m.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>J(!0)}):a?(0,G.jsx)(I.RequestTimeOff,{meId:a,me:Z,testID:"rota-requests-time-off"}):null,h.filter(e=>de||e.staffId===a).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,G.jsx)(m.Card,{children:(0,G.jsxs)(f.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(l.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,G.jsx)(m.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,G.jsxs)(m.Muted,{children:[(0,I.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&de?(0,G.jsxs)(m.Row,{gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),de&&a?(0,G.jsx)(I.TimeOffSheet,{visible:q,onClose:()=>J(!1),meId:a,me:Z,manager:!0}):null]}):null,'availability'===Y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.Muted,{children:["Days each person can\u2019t work. ",de?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),Ce.filter(e=>'owner'!==e.role||!de).map(e=>(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{gap:8,children:[(0,G.jsx)(M.StaffAvatar,{id:e.id,size:30}),(0,G.jsx)(m.T,{weight:"semibold",children:e.name})]}),(0,G.jsx)(m.Row,{wrap:!0,gap:4,children:O.DAY3.map((t,n)=>{const a=(c[e.id]??[]).includes(n);return(0,G.jsx)(m.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,L?(0,G.jsx)(V.AssignRoleSheet,{name:(l.find(e=>e.id===L.staffId)?.name??'Team member').replace(' (example)',''),when:`${(0,D.niceDate)((0,D.parseYmd)(L.date))} \xb7 ${(0,O.fmtH)(L.shift.start)}\u2013${(0,O.fmtH)(L.shift.end)}`,current:L.shift.badge,onSave:e=>{s.useOwner.getState().setShifts((0,U.assignShiftBadge)(s.useOwner.getState().shifts,L.shift.id,e)),N(null)},onEditTimes:()=>{z(L),N(null)},onClose:()=>N(null)}):null,A?(0,G.jsx)(ae,{init:A,onClose:()=>z(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:o,meId:h,me:g,r:p,rid:x}=(0,O.useCtx)(5e3),b=((0,P.useClockArea)(e=>e.areas[x]),(0,P.areaOf)(x));const w=(0,B.privateClockVenue)(x),[k,y]=(0,r.useState)(!1),[I,S]=(0,r.useState)(!1),C=(0,s.useOwner)(e=>e.consent[h]),T=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),$=(0,s.useOwner)(e=>e.shifts),[H,N]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(null),[F,E]=(0,r.useState)(null),[_,q]=(0,r.useState)(void 0),[U,V]=(0,r.useState)(null),[K,Q]=(0,r.useState)(!1),[X,J]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[te,se]=(0,r.useState)(!1),ne=T.filter(t=>t.staffId===h&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],ae=ne&&(0,s.isOnBreak)(ne)?ne.breaks[ne.breaks.length-1]:void 0,oe=(0,s.visibleShifts)($,'staff'!==o).find(e=>e.staffId===h&&e.date===t),le='staff'!==o,ie=ne?(0,O.paidMins)({in:ne.in},e).worked:0,re=b.on&&(0,R.areaSet)(b),ue=ne?.geo?.[ne.geo.length-1],he=T.filter(e=>e.staffId===h&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],fe=(0,d.useClockNotSent)(ne?.id??U?.id??he?.id),[me,ge]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(fe)ge(!0);else if(me){const e=setTimeout(()=>ge(!1),6e3);return()=>clearTimeout(e)}},[fe]);const pe=!fe&&me;(0,r.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>se(!1),4e3);return()=>clearTimeout(e)},[te]);const xe=async(s,n={})=>{W(s),E(null),q(void 0);const a=await(0,A.clockAction)(s,{rid:x,staffId:h,date:t,at:new Date(e.getTime()).toISOString(),...n});return W(null),!a.ok&&a.reclock?(ee(a.reclock),!1):a.ok?('out'===s&&a.att&&(V(a.att),se(!0),(0,i.hrSettingsOf)(p.settings?.hr).on&&!l.useHr.getState().hasAnswered(x,a.att.id)&&J(a.att)),'in'===s&&V(null),a.att&&(0,d.markClockUnsent)(a.att.id),!0):(E(a.message),q(a.fix),(0,z.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return C?(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.Row,{gap:10,style:{flex:1},children:[(0,G.jsx)(M.StaffAvatar,{id:h,size:48}),(0,G.jsx)(m.T,{weight:"semibold",style:{flex:1},children:g})]}),(0,G.jsx)(m.Badge,{kind:ne?'ok':'neutral',label:ne?`On shift since ${(0,D.hm)(new Date(ne.in))}`:'Not clocked in'})]}),(0,G.jsx)(m.Muted,{children:oe?`Today's shift: ${(0,O.fmtH)(oe.start)}\u2013${(0,O.fmtH)(oe.end)}`:'No shift on the rota today'}),(0,G.jsx)(f.default,{testID:"clock-area-line",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.muted,children:re?w?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ue&&!0===ue.inside&&null!=ue.dist?(0,G.jsxs)(m.Muted,{children:["Last check: at the venue (about ",ue.dist," m from the centre)."]}):null,ne?(0,G.jsx)(m.T,{size:30,weight:"bold",center:!0,children:(0,O.hmDur)(ie)}):null,ne&&ae?(0,G.jsx)(f.default,{testID:"on-break",children:(0,G.jsxs)(m.T,{size:15,weight:"semibold",colour:v.colours.gold,center:!0,children:["On a break since ",(0,D.hm)(new Date(ae.start))," \xb7 ",(0,s.loggedBreakMins)(ne,e)," min so far"]})}):null,!ne&&te?(0,G.jsx)(f.default,{testID:"clock-just-out",accessible:!0,accessibilityRole:"text",accessibilityLabel:"Clocked out",style:{minHeight:48,alignItems:'center',justifyContent:'center'},children:(0,G.jsx)(m.T,{size:17,weight:"semibold",colour:v.colours.ok,center:!0,children:"\u2713 Clocked out"})}):ne?(0,G.jsxs)(G.Fragment,{children:[ae?(0,G.jsx)(m.Button,{testID:"break-end",kind:"success",label:'break_end'===Y?'Checking your location\u2026':'End break',disabled:!!Y,onPress:()=>{xe('break_end')}}):(0,G.jsx)(m.Button,{testID:"break-start",kind:"secondary",label:'break_start'===Y?'Checking your location\u2026':'Start break',disabled:!!Y,onPress:()=>{xe('break_start')}}),(0,G.jsx)(m.Button,{testID:"clock-out",kind:"danger",label:'out'===Y?'Checking your location\u2026':'Clock out',disabled:!!Y,onPress:()=>{ne.breaks?.length?xe('out'):(E(null),N(!0))}})]}):(0,G.jsx)(m.Button,{testID:"clock-in",kind:"success",label:'in'===Y?'Checking your location\u2026':'Clock in',disabled:!!Y,onPress:()=>{const e=(0,a.recentClockOut)(T,h,new Date);e?ee(e):w?y(!0):xe('in')}}),fe?(0,G.jsxs)(f.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,G.jsx)(m.T,{size:18,weight:"bold",colour:v.colours.gold,center:!0,children:"Not sent yet"}),(0,G.jsx)(m.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,G.jsx)(m.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{c.mutationQueue.retryNow()}})]}):pe?(0,G.jsx)(f.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,G.jsx)(m.T,{size:14,colour:v.colours.ok,center:!0,children:"\u2713 Sent"})}):null,ne?.breaks?.length?(0,G.jsxs)(m.Muted,{center:!0,children:["Breaks today: ",ne.breaks.map(e=>`${(0,D.hm)(new Date(e.start))}\u2013${e.end?(0,D.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(ne,e)," min)"]}):null,F?(0,G.jsx)(f.default,{testID:"clock-message",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Not recorded",children:F})}):null,F&&'settings'===_?(0,G.jsx)(m.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:L.openAppSettings}):null,F&&'location'===_?(0,G.jsx)(m.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:L.openLocationSettings}):null,F&&'update'===_?(0,G.jsx)(m.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:L.checkAppUpdate}):null]}),le&&!(0,R.areaSet)(b)?(0,G.jsx)(f.default,{testID:"clock-area-warning",children:(0,G.jsx)(m.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,G.jsx)(u.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>Q(!0),style:{alignSelf:'center',padding:6},children:(0,G.jsx)(m.T,{size:14,colour:v.colours.gold,children:"Forgot to clock in or out?"})}),K?(0,G.jsx)(ce,{onClose:()=>Q(!1)}):null,(0,G.jsx)(j.BreakRoomCard,{staffId:h,name:g,now:e}),U?(()=>{const t=(0,O.paidMins)(U,e);return(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsxs)(m.T,{weight:"semibold",colour:v.colours.gold,children:["Clocked out at ",(0,D.hm)(new Date(U.out))]}),(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Clocked ",(0,O.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,O.hmDur)(t.paid)]}),(0,G.jsxs)(m.Muted,{children:["In ",(0,D.hm)(new Date(U.in))," \xb7 out ",(0,D.hm)(new Date(U.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",U.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,G.jsx)(m.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,G.jsx)(m.Sheet,{visible:k||I,onClose:()=>{y(!1),S(!1)},title:"Why we ask for location",testID:"clock-location-reason",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsxs)(m.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,G.jsx)(m.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,G.jsx)(m.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{const e=I;y(!1),S(!1),xe('in',e?{reclock:!0}:{})}}),(0,G.jsx)(m.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>{y(!1),S(!1)}})]})}),le?(0,G.jsx)(de,{rid:x,today:t,now:e}):null,(0,G.jsx)(m.Sheet,{visible:!!Z,onClose:()=>ee(null),title:"Clock in again?",testID:"clock-reclock",children:(0,G.jsxs)(f.default,{style:{gap:12},children:[(0,G.jsx)(m.T,{testID:"clock-reclock-text",accessibilityRole:"header",children:Z?(0,a.reclockQuestion)(Z):''}),(0,G.jsx)(m.Button,{testID:"clock-reclock-no",kind:"secondary",label:"No, stay clocked out",accessibilityLabel:"No, stay clocked out",onPress:()=>ee(null)}),(0,G.jsx)(m.Button,{testID:"clock-reclock-yes",kind:"success",label:"Yes, clock in again",accessibilityLabel:"Yes, clock in again",onPress:()=>{ee(null),w?S(!0):xe('in',{reclock:!0})}})]})}),X?(0,G.jsx)(n.ShiftCheckout,{rid:x,shiftKey:X.id,day:X.date,meId:h,onClose:()=>J(null)}):null,(0,G.jsx)(m.Sheet,{visible:H,onClose:()=>N(!1),title:"Did you take a break? If so, how long?",children:(0,G.jsxs)(f.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,G.jsx)(m.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,G.jsx)(m.Chip,{testID:`forgot-break-${e}`,label:(0,R.breakLabel)(e),disabled:e>=ie,onPress:()=>{N(!1),xe('out',{addedBreak:e})}},e))}),(0,G.jsx)(m.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{N(!1),xe('out',{breakMins:0})}}),ie>360?(0,G.jsx)(m.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,G.jsx)(m.Muted,{children:w?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,G.jsx)(f.default,{style:{gap:10},children:(0,G.jsxs)(m.Card,{highlight:v.colours.gold,children:[(0,G.jsx)(m.T,{weight:"semibold",colour:v.colours.gold,children:"Before you clock in: location & your privacy"}),w?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,G.jsx)(m.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,G.jsxs)(G.Fragment,{children:[" ",(0,G.jsxs)(m.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,G.jsx)(m.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,G.jsx)(m.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,G.jsx)(m.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(h,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,O.useCtx)(3e4);return s!=='staff'?(0,G.jsx)(he,{now:e,today:t,meId:n}):(0,G.jsx)(ue,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]);_r(_d[10]);var u=e(_r(_d[11])),h=e(_r(_d[12])),f=e(_r(_d[13])),m=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),B=_r(_d[33]),R=_r(_d[34]),A=_r(_d[35]),z=_r(_d[36]),L=_r(_d[37]),H=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),W=_r(_d[41]),F=_r(_d[42]),E=_r(_d[43]),_=_r(_d[44]),q=_r(_d[45]),U=_r(_d[46]),V=_r(_d[47]),K=_r(_d[48]),G=_r(_d[49]);const Q=e=>(0,k.deptKey)(e?.dept),X=(e,t)=>(0,k.canSwapWith)(e,t,y.VENUE_RID),J=2650,Z=1900,ee=e=>e.end-e.start,te=e=>e>8?.5:e>6?.3333333333333333:0,se=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,O.weekday)(e)),t};function ne(e){const{rid:t,r:s,now:n}=(0,O.useCtx)(6e4),a=(0,g.useBookings)(t),o=(0,g.useOrders)(t),l=(0,g.useEvents)(t),i=(0,N.useCashUp)(e=>e.cashUps),d=(0,H.useRealHistory)(t,n);return(0,r.useMemo)(()=>{const r=Array.from({length:7},(t,s)=>{const n=(0,D.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),c=(0,Y.clampWeeks)(s.settings.forecastMinWeeks);if(!d){const i=r.map(e=>{const t=(0,S.forecastToday)(s,a,o,l,e);return t.open?t.restOfDay.covers*J+t.restOfDay.takeaway*Z:0});return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:[],bookings:a,minWeeks:c,exampleSales:i})}return(0,W.weekSalesForRota)({rid:t,mon:e,now:n,kitchenHours:s.kitchenHours,cashUps:i,bookings:a,minWeeks:c})},[s,a,o,l,i,d,(0,D.ymd)(e)])}function ae({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,r.useState)(e.shift?.start??12),[l,i]=(0,r.useState)(e.shift?.end??20),[d,c]=(0,r.useState)(e.shift?.breakAt),[u,h]=(0,r.useState)((0,U.cleanBadge)(e.shift?.badge)),g=void 0===d||d>a&&dt.id===e.staffId),x=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,G.jsxs)(m.Sheet,{visible:!0,onClose:t,title:(0,q.shiftTitle)(p?.name??'',e.date),testID:"shift-sheet",children:[x?(0,G.jsx)(m.Banner,{kind:"warn",title:`${(p?.name??'').replace(' (example)','')} has time off: ${(0,I.rangeLabel)(x.from,x.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,G.jsx)(m.T,{center:!0,weight:"semibold",children:"Role badge for this shift"}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,G.jsx)(m.Chip,{label:"None",selected:!u,onPress:()=>h(void 0),testID:"shift-badge-none"}),U.ROLE_BADGES.map(e=>(0,G.jsx)(m.Chip,{label:e,selected:u===e,onPress:()=>h(u===e?void 0:e),testID:`shift-badge-${e.replace(/\s+/g,'-').toLowerCase()}`,accessibilityLabel:`${e} badge${u===e?', chosen, tap to remove':''}`},e))]}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,G.jsx)(m.Chip,{label:`${e} ${(0,O.fmtH)(t)}\u2013${(0,O.fmtH)(s)}`,selected:a===t&&l===s,onPress:()=>{o(t),i(s)}},e))}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{children:"Start"}),(0,G.jsx)(m.Stepper,{testID:"shift-start",value:a,step:.5,min:q.SHIFT_MIN_START,max:l-1,onChange:o,format:O.fmtH,label:"Start time"})]}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:"End"}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.Stepper,{testID:"shift-end",value:l,step:.5,min:a+1,max:q.SHIFT_MAX_END,onChange:i,format:O.fmtH,label:"End time"}),l>=24?(0,G.jsx)(m.Muted,{children:"next day"}):null]})]}),(0,G.jsxs)(m.Muted,{children:[(l-a).toFixed(1),"h scheduled",te(l-a)?`, ${Math.round(60*te(l-a))}m planned break`:'']}),(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,G.jsx)(m.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,G.jsx)(m.Chip,{label:"Set a break time",onPress:()=>c(Math.min(l-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(l-a)/2)))/4)))}):(0,G.jsxs)(m.Row,{gap:6,children:[(0,G.jsx)(m.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:l-.25,onChange:c,format:O.fmtH,label:"Break time"}),(0,G.jsx)(m.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,G.jsx)(m.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,G.jsx)(m.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:l,breakAt:g?d:void 0,badge:(0,U.cleanBadge)(u),changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:l,...void 0!==d&&g?{breakAt:d}:{},...(0,U.cleanBadge)(u)?{badge:(0,U.cleanBadge)(u)}:{}}),t()}}),(0,G.jsx)(m.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,G.jsx)(m.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const oe=6;function le(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*oe:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+oe),big:o>=104,fits:!e||s+t*(o+oe)<=e}}const ie={position:'sticky',top:0};function re({fits:e,children:t}){return e?(0,G.jsx)(f.default,{style:{alignItems:'center'},children:t}):(0,G.jsx)(h.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function de({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,O.useSignedIn)(),{me:i,meId:d}=(0,O.useCtx)(3e4),[c,u]=(0,r.useState)(null),[h,f]=(0,r.useState)(''),[g,p]=(0,r.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,A.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:l?.id??d,name:l?.name??i},h);if(!n.ok)return void p(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,z.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),f(''),p(null)};return(0,G.jsxs)(m.Card,{children:[(0,G.jsx)(m.T,{weight:"semibold",children:"Record it for someone"}),(0,G.jsx)(m.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:a.map(e=>(0,G.jsx)(m.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Field,{label:"Reason (kept with the record)",value:h,onChangeText:f,placeholder:"e.g. Phone out of battery"}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,G.jsx)(m.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),g?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:g}):null]}):null]})}function ce({onClose:e}){const{now:t,today:n,meId:a}=(0,O.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),l=(0,s.useOwner)(e=>e.shifts),i=Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),[d,c]=(0,r.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(l,!1).find(e=>e.staffId===a&&e.date===d),[f,g]=(0,r.useState)(u&&!u.out?'out':'in'),[p,x]=(0,r.useState)(h?Math.round(60*h.start):720),[j,w]=(0,r.useState)(h?Math.round(60*h.end):1200),[k,y]=(0,r.useState)(''),[I,S]=(0,r.useState)(!1),C=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,T='out'!==f,$='in'!==f,M=T&&$&&j<=p,P=(e,t)=>(0,G.jsx)(m.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,G.jsx)(m.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,G.jsx)(m.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,G.jsx)(m.Button,{label:"Done",onPress:e})]}):(0,G.jsxs)(m.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,G.jsx)(m.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,children:i.map(e=>(0,G.jsx)(m.Chip,{label:e===n?'Today':(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,G.jsxs)(m.Muted,{children:[h?`Your rota that day: ${(0,O.fmtH)(h.start)}\u2013${(0,O.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,D.hm)(new Date(u.in))}\u2013${u.out?(0,D.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,G.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,G.jsx)(m.Chip,{label:"Forgot to clock in",selected:'in'===f,onPress:()=>g('in')}),(0,G.jsx)(m.Chip,{label:"Forgot to clock out",selected:'out'===f,onPress:()=>g('out')}),(0,G.jsx)(m.Chip,{label:"Forgot both",selected:'both'===f,onPress:()=>g('both')})]}),T?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["In ",C(p)]}),P(x,p)]}):null,$?(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(m.T,{size:18,weight:"bold",children:["Out ",C(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,G.jsx)(m.T,{size:13,colour:v.colours.red,children:"Clock-out must be after clock-in."}):null,(0,G.jsx)(m.Field,{label:"Note for your manager (optional)",value:k,onChangeText:y,placeholder:"e.g. phone died",maxLength:200}),(0,G.jsx)(m.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:f,suggestedIn:T?(0,b.isoAt)(d,p):void 0,suggestedOut:$?(0,b.isoAt)(d,j):void 0,note:k.trim(),at:t.toISOString()}),S(!0)}})]})}function ue(){const{now:e,today:t,meId:n}=(0,O.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),l=(0,s.useOwner)(e=>e.timeRequests),[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null),h=(0,D.ymd)(se(e)),g=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),p=g.filter(e=>e.date>=h),x=p.filter(s.isConfirmed).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),j=p.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),w=l.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,G.jsxs)(f.default,{style:{gap:10},testID:"my-timesheet",children:[(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,G.jsxs)(f.default,{children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,G.jsx)(m.T,{size:28,weight:"bold",colour:v.colours.ok,children:(0,O.hmDur)(x)})]}),(0,G.jsxs)(f.default,{style:{alignItems:'flex-end'},children:[(0,G.jsx)(m.T,{size:12,colour:v.colours.muted,children:"PENDING SIGN-OFF"}),(0,G.jsx)(m.T,{size:18,weight:"semibold",colour:j?v.colours.amber:v.colours.muted,children:(0,O.hmDur)(j)})]})]}),(0,G.jsx)(m.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,G.jsx)(m.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,G.jsx)(T.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsxs)(m.T,{size:14,children:[(0,D.niceDate)((0,D.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,G.jsxs)(m.Muted,{children:[e.suggestedIn?`in ${(0,D.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,D.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,G.jsx)(m.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,G.jsx)(T.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),g.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,O.paidMins)(t,e),l=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,G.jsxs)(m.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsxs)(f.default,{style:{flex:1},children:[(0,G.jsx)(m.T,{weight:"semibold",children:(0,D.niceDate)((0,D.parseYmd)(t.date))}),(0,G.jsxs)(m.Muted,{children:[(0,D.hm)(new Date(t.in)),"\u2013",t.out?(0,D.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,O.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,O.fmtH)(n.start)}\u2013${(0,O.fmtH)(n.end)}`:'']})]}),(0,G.jsx)(m.Badge,{kind:(0,b.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,b.statusLabel)(t)})]}),l?(0,G.jsxs)(m.T,{size:13,colour:v.colours.gold,children:["Adjusted by ",l.by.replace(' (example)',''),l.reason?`: ${l.reason}`:'']}):null,t.signOff?(0,G.jsxs)(m.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,G.jsx)(b.AuditTrail,{a:t}):null]},t.id)}),g.length?null:(0,G.jsx)(m.Muted,{children:"No clocked shifts yet."}),i?(0,G.jsx)(ce,{onClose:()=>d(!1)}):null]})}function he({now:e,today:n}){const a=(0,s.useOwner)(e=>e.staff),l=(0,s.useOwner)(e=>e.shifts),i=(0,O.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),c=(0,s.useOwner)(e=>e.timeRequests),h=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.attLog),[x,j]=(0,r.useState)(n),[w,k]=(0,r.useState)(null),[y,I]=(0,r.useState)(!1),[S,$]=(0,r.useState)(!1),P=!!(0,O.useSignedIn)(),B=S?(0,F.pastWeekDays)(x,n):Array.from({length:7},(e,t)=>(0,D.ymd)((0,D.addMins)((0,D.parseYmd)(n),1440*-t))),R=d.filter(e=>e.date===x&&e.in),A=l.filter(e=>e.date===x&&!1!==e.published).filter(e=>!R.some(t=>t.staffId===e.staffId)),z=d.filter(e=>B.includes(e.date)&&e.out),L=z.filter(s.isConfirmed),H=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),N=z.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,O.paidMins)(s,e).paid,0),Y=L.reduce((t,s)=>t+(0,O.paidMins)(s,e).paid/60*(i[s.staffId]??0),0),W=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(L.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=a.find(e=>e.id===t.staffId),o=(0,s.shiftOf)(l,t.staffId,t.date),r=(0,O.paidMins)(t,e),d=i[t.staffId]??0;return`${n?.name},${t.date},${o?`${(0,O.fmtH)(o.start)}-${(0,O.fmtH)(o.end)}`:'-'},${(0,D.hm)(new Date(t.in))},${(0,D.hm)(new Date(t.out))},${r.brk},${(r.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(r.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==i[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,G.jsxs)(f.default,{style:{gap:10},children:[(0,G.jsx)(E.HoursDayPicker,{testID:"ts-pick",date:x,today:n,custom:S,onDate:e=>{j(e),$(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),$(!1)}}),(0,G.jsx)(m.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:B.map(e=>(0,G.jsx)(m.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,F.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':S?(0,F.chipDay)(e):(0,D.niceDate)((0,D.parseYmd)(e)).slice(0,6).trim(),selected:x===e,onPress:()=>j(e)},e))}),(0,G.jsxs)(m.Card,{children:[(0,G.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,G.jsx)(m.T,{weight:"semibold",testID:"ts-week-title",children:S?(0,F.weekTitle)(x,n):'Last 7 days'}),(0,G.jsx)(m.Badge,{kind:"ok",label:`${(0,O.hmDur)(H)} confirmed`})]}),N?(0,G.jsxs)(m.T,{size:13,colour:v.colours.amber,children:[(0,O.hmDur)(N)," pending sign-off (not counted yet)"]}):null,(0,G.jsxs)(m.Muted,{children:["Labour cost ",(0,C.gbp)(Math.round(Y))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,G.jsx)(o.WideTable,{children:(0,G.jsxs)(f.default,{style:{gap:2},children:[(0,G.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:v.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,G.jsx)(m.T,{size:12,weight:"semibold",colour:v.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),R.map(t=>{const i=a.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(l,t.staffId,x),d=(0,O.paidMins)(t,e),h=(0,b.flagsFor)(t,r,e,n,c).map(e=>e.label);return(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,G.jsxs)(m.Row,{gap:4,style:{width:110},children:[(0,G.jsx)(M.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,G.jsx)(m.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:i?.name.replace(' (example)','')})]}),(0,G.jsx)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:r?`${(0,O.fmtH)(r.start)}\u2013${(0,O.fmtH)(r.end)}`:'\u2013'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:(0,D.hm)(new Date(t.in))}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?(0,D.hm)(new Date(t.out)):'on'}),(0,G.jsx)(m.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,G.jsx)(m.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,O.hmDur)(d.paid):`${(0,O.hmDur)(d.worked)}\u2026`}),(0,G.jsx)(m.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?v.colours.ok:'open'===(0,s.attStatus)(t)?v.colours.blue:v.colours.amber,children:(0,b.statusLabel)(t)}),(0,G.jsx)(m.T,{size:11,style:{width:140},colour:h.length?v.colours.amber:v.colours.ok,children:h.join(', ')||'OK'}),(0,G.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${i?.name}`,onPress:()=>k(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,G.jsx)(m.T,{size:12,colour:v.colours.gold,children:"Edit"})})]},t.id)}),A.map(t=>(0,G.jsxs)(o.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,G.jsx)(m.T,{size:12,style:{width:110},children:a.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,G.jsxs)(m.T,{size:12,style:{width:86},colour:v.colours.muted,children:[(0,O.fmtH)(t.start),"\u2013",(0,O.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(h,t.staffId,t.date);return s?(0,G.jsxs)(m.T,{size:12,colour:v.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,G.jsx)(m.T,{size:12,colour:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?v.colours.muted:v.colours.red,children:x===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),R.length||A.length?null:(0,G.jsx)(m.Muted,{children:"No shifts or clock records for this day."}),(0,G.jsx)(m.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,G.jsx)(m.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>I(!0)}),(0,G.jsx)(T.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),g.length?g.slice(0,12).map(e=>(0,G.jsxs)(m.Muted,{children:[(0,D.niceDate)(new Date(e.at))," ",(0,D.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,G.jsx)(m.Muted,{children:"No manual changes yet."}),w?(0,G.jsx)(b.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>k(null)}):null,(0,G.jsxs)(m.Sheet,{visible:y,onClose:()=>I(!1),title:"Payroll export",children:[(0,G.jsxs)(m.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",N?`${(0,O.hmDur)(N)} still pending sign-off is left out.`:'']}),(0,G.jsxs)(f.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[W.slice(0,14).map((e,t)=>(0,G.jsx)(m.T,{size:10,colour:t?v.colours.text:v.colours.gold,children:e},t)),W.length>14?(0,G.jsxs)(m.Muted,{children:["\u2026 ",W.length-14," more rows"]}):null]}),(0,G.jsxs)(m.Muted,{children:[W.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1196,[813,876,1197,1070,1177,923,924,17,975,976,219,385,278,85,777,858,1071,1198,1187,1163,1199,1059,805,1200,1140,851,863,804,1178,1161,1057,884,1012,912,913,1067,916,1069,1145,1008,1142,1143,1190,1192,1051,1060,1168,1167,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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1197,[812,17,385,85,777,804,876,816,860,923,924,8]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"hmClock",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hmDur",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"plannedBreakMins",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"plannedNetMins",{enumerable:!0,get:function(){return d}}),e.breakMinutes=s,e.paidMinutes=l,Object.defineProperty(e,"isConfirmedAtt",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isOpenAtt",{enumerable:!0,get:function(){return h}}),e.attendanceOnDate=p,e.confirmedOnDate=b,e.openOnDate=m,e.diffLabelOf=w,e.rotaCellWorked=function(t,o,u,d,s){const c=t?`${(0,n.fmtH)(t.start)}\u2013${(0,n.fmtH)(t.end)}`:void 0;if(!s)return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'};const h=b(o,u,d);if(h?.in&&h.out){const n=l(h)??0,o=`Worked ${a(h.in)}\u2013${a(h.out)} \xb7 ${f(n)}`,u=t?w(t,h):{differs:!1},d=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift',`worked ${a(h.in)} to ${a(h.out)}, ${f(n)}`,u.diffLabel].filter(Boolean).join(', ');return{plannedLabel:c,workedLine:o,onShiftNow:!1,differs:u.differs,diffLabel:u.diffLabel,speech:d}}if(m(o,u,d)){const n=[c?`planned ${c.replace('\u2013',' to ')}`:'no planned shift','on shift now'].join(', ');return{plannedLabel:c,onShiftNow:!0,differs:!1,speech:n}}return{plannedLabel:c,onShiftNow:!1,differs:!1,speech:c?`planned ${c.replace('\u2013',' to ')}`:'no shift'}};var n=r(_d[0]);const t=n=>String(n).padStart(2,'0'),o=5,a=n=>{const o=new Date(n);return`${t(o.getHours())}:${t(o.getMinutes())}`},f=n=>`${Math.floor(Math.max(0,n)/60)}h ${t(Math.max(0,n)%60)}m`,u=n=>n>8?30:n>6?20:0,d=n=>{const t=Math.round(60*(n.end-n.start));return Math.max(0,t-u(n.end-n.start))};function s(n,t=new Date){if('number'==typeof n.breakMins)return n.breakMins;const o=t.getTime();return Math.round((n.breaks??[]).reduce((n,t)=>n+Math.max(0,(t.end?new Date(t.end).getTime():o)-new Date(t.start).getTime()),0)/6e4)}function l(n,t=new Date){if(!n.in)return null;const o=n.out?new Date(n.out):t,a=Math.max(0,Math.round((o.getTime()-new Date(n.in).getTime())/6e4));return Math.max(0,a-s(n,t))}const c=n=>!(n.voided||!n.in||!n.out||!n.signOff),h=n=>!n.voided&&!!n.in&&!n.out;function p(n,t,o){return n.filter(n=>n.staffId===t&&n.date===o&&!n.voided)}function b(n,t,o){const a=p(n,t,o).filter(c);if(!a.length)return null;if(1===a.length)return a[0];const f=a.reduce((n,t)=>n.inn.out>t.out?n:t),d=a.reduce((n,t)=>n+s(t),0);return{staffId:t,date:o,in:f.in,out:u.out,breakMins:d,signOff:f.signOff}}function m(n,t,o){return p(n,t,o).find(h)??null}function M(n){const t=new Date(n);return 60*t.getHours()+t.getMinutes()}function $(n){return(Math.round(60*n)%1440+1440)%1440}function w(n,t){const a=l(t),u=d(n);if(null==a)return{differs:!1};const s=Math.abs(M(t.in)-$(n.start)),c=t.out?Math.abs(M(t.out)-$(n.end>=24?n.end-24:n.end)):0,h=a-u;if(Math.abs(h)>o){const n=Math.abs(h);return{differs:!0,diffLabel:h>0?`${f(n)} longer than planned`:`${f(n)} shorter than planned`}}return s>o||c>o?{differs:!0,diffLabel:'Times differ from the plan'}:{differs:!1}}},1198,[1060]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1199,[17,85,777,876,1059,804,1071,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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1200,[17,385,85,777,876,863,804,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:s}=(0,c.useCtx)(3e4),h=(0,c.useSignedIn)(),u=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),y=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave);if(!h)return null;const b=(0,l.openShiftOf)(u,h.id,t),p=!!b?.breaks?.some(e=>!e.end),I=(0,f.workingShifts)(y,x).filter(e=>e.staffId===h.id&&e.date===s),S=(0,f.leaveCovering)(x,h.id,s),v=S?`${(0,f.leaveLabel)(S)} today`:I.length?I.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,w.jsx)(n.default,{testID:"my-shift-card",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:v}),(0,w.jsx)(k,{staffId:h.id}),(0,w.jsx)(o.T,{center:!0,children:b?p?'On a break':`Clocked in since ${j(b.in)}`:'Not clocked in'}),(0,w.jsx)(o.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,w.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,w.jsx)(o.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,w.jsx)(o.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,w.jsx)(o.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=k;var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),l=r(_d[3]),d=r(_d[4]),c=r(_d[5]),h=r(_d[6]),u=r(_d[7]),f=r(_d[8]),y=r(_d[9]),w=r(_d[10]);const j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function k({staffId:e,team:s}){const{today:j}=(0,c.useCtx)(6e4),k=(0,l.useOwner)(e=>e.shifts),x=(0,l.useOwner)(e=>e.leave),[b,p]=(0,t.useState)(y.UPCOMING_WEEKS_DEFAULT),{visible:I,hasMore:S,all:v}=(0,t.useMemo)(()=>(0,y.upcomingMine)(k,e,j,b),[k,e,j,b]),M=b>y.UPCOMING_WEEKS_DEFAULT,C=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),D=v.length?I.length?'':b===y.UPCOMING_WEEKS_DEFAULT?'No shifts in the next two weeks.':'No shifts in these weeks.':'No shifts on the rota yet.';return(0,w.jsx)(n.default,{testID:"my-upcoming-shifts",children:(0,w.jsxs)(o.Card,{children:[(0,w.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),I.length?I.map(t=>(0,w.jsxs)(n.default,{style:{gap:4},children:[(0,w.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(o.T,{children:C(t.date)}),(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(o.T,{colour:d.colours.blue,children:(0,f.leaveLabel)((0,f.leaveCovering)(x,t.staffId,t.date))}):(0,w.jsxs)(o.T,{children:[(0,h.fmtH)(t.start),"\u2013",(0,h.fmtH)(t.end)]})]}),s&&!(0,f.leaveCovering)(x,t.staffId,t.date)?(0,w.jsx)(u.TeamOnDay,{date:t.date,meId:e,label:C(t.date)}):null]},t.id)):(0,w.jsx)(o.Muted,{center:!0,children:D}),S||M?(0,w.jsxs)(n.default,{testID:"my-shifts-week-actions",style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:8},children:[S?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show more weeks",testID:"my-shifts-show-more",accessibilityLabel:"Show more weeks",accessibilityHint:"Shows two more weeks of your published shifts.",onPress:()=>p(e=>(0,y.moreUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null,M?(0,w.jsx)(o.Button,{kind:"secondary",label:"Show fewer",testID:"my-shifts-show-fewer",accessibilityLabel:"Show fewer weeks",accessibilityHint:"Hides the last two weeks added.",onPress:()=>p(e=>(0,y.fewerUpcomingWeeks)(e)),style:{minHeight:56,alignSelf:'stretch',width:'100%'}}):null]}):null]})})}},1201,[17,85,777,876,804,1057,1060,1199,1071,1202,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UPCOMING_WEEKS_DEFAULT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UPCOMING_WEEKS_STEP",{enumerable:!0,get:function(){return a}}),e.upcomingEndDate=o,e.upcomingMine=function(t,n,a,u){const c=t.filter(t=>t.staffId===n&&!1!==t.published&&t.date>=a).sort((t,n)=>t.date.localeCompare(n.date)||(t.start??0)-(n.start??0)),s=o(a,u);return{all:c,visible:c.filter(t=>t.date<=s),hasMore:c.some(t=>t.date>s)}},e.moreUpcomingWeeks=function(t){return Math.max(n,t)+a},e.fewerUpcomingWeeks=function(t){return Math.max(n,t-a)};var t=r(_d[0]);const n=2,a=2;function o(a,o){const u=Math.max(n,o),c=(0,t.parseYmd)(a);return c.setDate(c.getDate()+7*u-1),(0,t.ymd)(c)}},1202,[863]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1203,[17,85,1057,804,777,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhosOnShift=function({compact:t=!1,marquee:s=!1}={}){const{today:u}=(0,o.useCtx)(15e3),p=(0,l.useOwner)(e=>(0,l.liveAttendance)(e.attendance)),j=(0,l.useOwner)(e=>e.staff),I=(0,r.workingNow)(p,j,u),D=(0,r.cardSpeech)(I),[k,v]=(0,e.useState)(0),[L,S]=(0,e.useState)(0),[W,O]=(0,e.useState)(y);if((0,e.useEffect)(()=>{t&&s&&x()},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'function'!=typeof window.matchMedia)return;const e=window.matchMedia('(prefers-reduced-motion: reduce)'),n=()=>O(!!e.matches);return n(),e.addEventListener?e.addEventListener('change',n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener('change',n):e.removeListener(n)}},[t,s]),(0,e.useEffect)(()=>{if(!t||!s||!f||'undefined'==typeof ResizeObserver)return;const e=document.querySelector('[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]');if(!e)return;const n=()=>{const t=e.querySelector('[data-testid="whos-on-shift-list"]');v(e.clientWidth),t&&S(Math.max(t.scrollWidth,t.offsetWidth))},o=new ResizeObserver(n);o.observe(e);const l=e.querySelector('[data-testid="whos-on-shift-list"]');return l&&o.observe(l),n(),()=>o.disconnect()},[t,s,I.length,D]),t&&s){const e=k>0&&L>k+1&&f&&!W,t=w.find(e=>e>=Math.round((L+48)/32))??80,s=0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,numberOfLines:1,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",children:(0,h.jsx)(b,{rows:I,testIds:!0})});return(0,h.jsxs)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:0,paddingHorizontal:10,height:44,maxHeight:44,minHeight:44,overflow:'hidden',width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',gap:8},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",numberOfLines:1,style:{flexShrink:0},children:r.CARD_TITLE}),(0,h.jsxs)(n.default,{testID:"whos-on-shift-marquee",onLayout:e=>v(e.nativeEvent.layout.width),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,height:44,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:[(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",onLayout:e=>S(e.nativeEvent.layout.width),style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row',flexWrap:'nowrap',flexShrink:0,width:'max-content'},children:(0,h.jsx)(b,{rows:I,testIds:!1})}),e?(0,h.jsxs)(n.default,{dataSet:{ccwho:`tick-${t}`},style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center'},children:[(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:s}),(0,h.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,paddingRight:48},children:(0,h.jsx)(b,{rows:I,testIds:!1})})]}):(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',flexShrink:0,width:'max-content'},children:s})]})]})}if(t)return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,style:{paddingVertical:2,paddingHorizontal:10,alignItems:'stretch',justifyContent:'center',flexShrink:1,minWidth:0,maxWidth:'100%',minHeight:44,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',gap:8,justifyContent:'flex-start',alignItems:'center',minWidth:0,maxWidth:'100%',width:'100%'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:13,colour:d.colours.gold,accessibilityRole:"header",testID:"whos-on-shift-title",style:{flexShrink:0},children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:13,colour:d.colours.muted,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{flexDirection:'row',flexWrap:'wrap',columnGap:10,rowGap:2,justifyContent:'flex-start',alignItems:'center',flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})});return(0,h.jsx)(n.default,{testID:"whos-on-shift",accessible:!0,accessibilityLabel:D,children:(0,h.jsxs)(c.Card,{style:{alignItems:'center'},children:[(0,h.jsx)(c.T,{weight:"semibold",size:22,colour:d.colours.gold,center:!0,accessibilityRole:"header",testID:"whos-on-shift-title",children:r.CARD_TITLE}),0===I.length?(0,h.jsx)(c.T,{size:18,colour:d.colours.muted,center:!0,testID:"whos-on-shift-empty",children:r.NOBODY}):(0,h.jsx)(n.default,{testID:"whos-on-shift-list",style:{gap:14,alignItems:'center',alignSelf:'stretch',width:'100%'},children:I.map(e=>(0,h.jsxs)(n.default,{testID:`whos-on-shift-${e.staffId}`,accessible:!0,accessibilityLabel:e.speech,style:{alignItems:'center',gap:2,minHeight:48,justifyContent:'center'},children:[(0,h.jsx)(c.T,{size:20,weight:"semibold",colour:d.colours.text,center:!0,children:e.name}),(0,h.jsx)(c.T,{size:16,colour:d.colours.muted,center:!0,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})]})})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]);const f='undefined'!=typeof document,w=[18,24,32,40,50,64,80],u=`\n[data-testid="display-whos-on-top"]{overflow:hidden;max-width:100%;width:100%}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"],\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"] *{flex-wrap:nowrap!important;white-space:nowrap}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-list"]{display:inline-flex!important;flex-direction:row;align-items:center;width:max-content!important;max-width:none!important}\n[data-testid="display-whos-on-top"] [data-testid="whos-on-shift-marquee"]>[data-ccwho],[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;width:max-content}\n${w.map(e=>`[data-testid="display-whos-on-top"] [data-ccwho="tick-${e}"]{display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;white-space:nowrap;animation:ccwho-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccwho-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-testid="display-whos-on-top"] [data-ccwho^="tick"]{animation:none!important}}\n`;let p=!1;function x(){if(!f||p)return;p=!0;const e=document.createElement('style');e.setAttribute('data-ccwho-css','1'),e.textContent=u,document.head.appendChild(e)}const y=()=>f&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;function b({rows:e,testIds:t}){return(0,h.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',columnGap:10,flexShrink:0,width:'max-content'},children:e.map(e=>(0,h.jsxs)(n.default,{testID:t?`whos-on-shift-${e.staffId}`:void 0,accessible:t,accessibilityLabel:t?e.speech:void 0,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:4,flexShrink:0},children:[(0,h.jsx)(c.T,{size:13,weight:"semibold",colour:d.colours.text,numberOfLines:1,children:e.name}),(0,h.jsx)(c.T,{size:12,colour:d.colours.muted,numberOfLines:1,children:e.inLabel}),e.onBreak?(0,h.jsx)(c.Badge,{kind:"amber",label:"On break"}):null]},e.id))})}},1204,[17,219,85,1057,876,1205,804,777,8]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysYmd",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"displayName",{enumerable:!0,get:function(){return o}}),e.isOpenBreak=a,e.openWorkingRows=s,e.workingNow=function(n,t,u){const d=new Map(t.map(n=>[n.id,n]));return s(n,u).flatMap(n=>{const t=d.get(n.staffId)?.name,s=t?o(t):'';if(!s)return[];const c=n.date===u?r(n.in):`${r(n.in)} yesterday`,f=a(n),p=f?`${s}, signed in at ${c}, on break`:`${s}, signed in at ${c}`;return[{id:n.id,staffId:n.staffId,name:s,inAt:n.in,inLabel:c,onBreak:f,speech:p}]})},Object.defineProperty(e,"NOBODY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CARD_TITLE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cardSpeech",{enumerable:!0,get:function(){return c}});const n=n=>String(n).padStart(2,'0'),t=(t,r)=>{const[o,a,s]=t.split('-').map(Number),u=new Date(o,a-1,s+r);return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`},r=t=>{const r=new Date(t);return`${n(r.getHours())}:${n(r.getMinutes())}`},o=n=>n.replace(' (example)','').trim();function a(n){return!!(n.breaks??[]).some(n=>!n.end)}function s(n,r){const o=t(r,-1),a=n.filter(n=>!n.voided&&n.in&&!n.out&&(n.date===r||n.date===o)),s=new Map;for(const n of a){const t=s.get(n.staffId);(!t||n.in>t.in)&&s.set(n.staffId,n)}return[...s.values()].sort((n,t)=>n.in.localeCompare(t.in))}const u='Nobody signed in',d="Who's on shift",c=n=>n.length?`${d}. ${n.map(n=>n.speech).join('. ')}.`:`${d}. ${u}.`},1205,[]); +__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.AccidentBook=function({me:e,meId:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1206,[812,1033,17,385,85,777,1003,804,889,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.MissedBanner=D,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s,rid:o}){const[l,r]=(0,d.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===s?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===s?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],m={me:e,meId:t,now:n,mode:s},x=(0,v.useMaySendInspectorLog)(m);x&&u.splice(u.findIndex(e=>'report'===e.id)+1,0,c('inspector','Inspector'));return u.splice(1,0,c('cooksafe','CookSafe records')),(0,C.jsxs)(h.default,{style:{gap:12},testID:"haccp-log",children:[(0,C.jsx)(i.TempSaveBanner,{}),'today'!==l?(0,C.jsx)(D,{mode:s,now:n,onPress:()=>r('today')}):null,(0,C.jsx)(f.Tabs,{value:l,onChange:r,options:u}),'today'===l?(0,C.jsx)(w.TodayView,{who:m}):null,'cooksafe'===l?(0,C.jsx)(k.CookSafeRecords,{who:m,rid:o}):null,'units'===l?(0,C.jsx)(w.UnitsView,{who:m}):null,'record'===l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(R,{who:m}),(0,C.jsx)(B,{who:m})]}):null,'diary'===l?(0,C.jsx)(w.DiaryView,{who:m}):null,'weekly'===l?(0,C.jsx)(w.WeeklyView,{who:m}):null,'report'===l?(0,C.jsx)(w.ReportView,{who:m}):null,'inspector'===l&&x?(0,C.jsx)(v.InspectorView,{who:m}):null,'history'===l?(0,C.jsx)(L,{who:m}):null,'limits'===l?(0,C.jsx)(A,{mode:s,editable:'chef'===s}):null,'probes'===l?(0,C.jsx)(M,{mode:s,me:e,now:n}):null,(0,C.jsx)(p.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. This is your CookSafe log (Food Standards Scotland): cross-contamination and allergens, cleaning, chilled storage and cooling, cooking, reheating and hot holding, management and records. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8])),u=e(_r(_d[9])),h=e(_r(_d[10])),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]);const S=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function D({now:e,onPress:t,mode:n="managers"}){const s=(0,o.useSafetyView)(n).points,i=(0,o.useSafetyView)(n).entries,l=(0,x.missedChecks)(s,i,e);if(!l.length)return(0,C.jsx)(h.default,{testID:"haccp-uptodate",children:(0,C.jsx)(p.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,C.jsx)(h.default,{testID:"haccp-missed",children:(0,C.jsx)(p.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function P(e,t){m.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,l.chefCanSee)(r.useOwner.getState().site,t.point)).map(t=>{const n=(0,x.isTempKind)(t.point.kind)?(0,x.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,x.initialsOf)(e.me)}}))}function R({who:e}){const i=(0,o.useSafetyView)(e.mode).points,[c,m]=(0,d.useState)(''),[y,w]=(0,d.useState)(null),[v,k]=(0,d.useState)(''),[S,T]=(0,d.useState)(!1),[D,R]=(0,d.useState)(!1),B=(0,d.useRef)(null),L=(t,n)=>{if('chef'===e.mode&&!(0,l.chefCanSee)(r.useOwner.getState().site,t))return w(null),void k('That check is managed in the Managers app.');const s=(0,x.parseQuick)(t,i);R(n),k(''),w(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,x.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},$=(e,t)=>w(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),A=(y??[]).map(e=>{const t=i.find(t=>t.id===e.pointId),n=I(e.value),s=!!t&&(0,x.isTempKind)(t.kind),o=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,x.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:o,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),O=A.length>0&&A.every(e=>e.ready&&!e.needsAction);return(0,C.jsxs)(f.Box,{testID:"haccp-quick",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Quick entry: type readings"}),(0,C.jsx)(p.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:c,onChangeText:m,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>L(c,!1),style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),n.MIC_OUTSIDE_DISPLAY?(0,C.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,j.speechRecognition)();if(!e)return void k("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(S)return void B.current?.stop();const t=new e;B.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';m(t),t&&L(t,!0)},t.onerror=()=>k("Didn't catch that. Try again or type the readings."),t.onend=()=>T(!1);try{t.start(),T(!0)}catch{k("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:b.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:S?b.colours.gold:'transparent'},children:(0,C.jsx)(p.T,{size:20,children:S?'\u25a0':'\ud83c\udfa4'})}):null]}),(0,C.jsx)(p.Button,{label:"Check readings",disabled:!c.trim(),onPress:()=>L(c,!1)}),v?(0,C.jsx)(h.default,{testID:"haccp-quick-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:v})}):null,y?(0,C.jsxs)(h.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,C.jsxs)(p.T,{weight:"semibold",children:["Check these ",y.length," reading",1===y.length?'':'s']}),A.map(({d:e,point:n,temp:o,ok:l,needsAction:r})=>(0,C.jsxs)(h.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?b.colours.red:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,C.jsx)(s.GoldClose,{size:"sm",label:`Remove ${n?.name??e.text}`,onPress:()=>w(t=>t.filter(t=>t.key!==e.key))})]}),n?(0,C.jsxs)(p.T,{weight:"semibold",children:[n.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 safe: ",(0,x.limitText)(n)]})]}):(0,C.jsxs)(h.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{colour:b.colours.amber,children:e.problem}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:i.map(t=>(0,C.jsx)(p.Chip,{label:t.name,onPress:()=>$(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),n&&o?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${n.name}`,value:e.value,onChangeText:t=>$(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:96,fontSize:20}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===l?(0,C.jsx)(p.Badge,{kind:"amber",label:"Type the reading"}):(0,C.jsx)(p.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,n&&!o?(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===e.done,onPress:()=>$(e.key,{done:!0})}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>$(e.key,{done:!1})})]}):null,!1===l?(0,C.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${n.name}`,value:e.corrective,onChangeText:t=>$(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[p.styles.input,r&&{borderColor:b.colours.red}]}):null,r?(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:`Save ${A.length} reading${1===A.length?'':'s'}`,testID:"haccp-save-quick",disabled:!O,onPress:()=>{P(e,A.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:D?'voice':'typed'}))),k(`Saved ${A.length} reading${1===A.length?'':'s'}.`),w(null),m('')},style:{flex:1}}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:()=>{w(null),k('Nothing saved.')}})]}),(0,C.jsx)(p.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function B({who:e}){const n=(0,o.useSafetyView)(e.mode).points,[s,i]=(0,d.useState)(n[0]?.id),[l,r]=(0,d.useState)(''),[c,u]=(0,d.useState)(),[h,m]=(0,d.useState)(''),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),k=n.find(e=>e.id===s),S=!!k&&(0,x.isTempKind)(k.kind),T=I(l),D=k?S?null==T?null:(0,x.inRange)(k,T):void 0===c?null:c:null,R=null!==D&&(D||h.trim());return(0,C.jsxs)(f.Box,{testID:"haccp-manual",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Record one check"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:n.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),r(''),u(void 0),m(''),v('')}},e.id))}),k?(0,C.jsxs)(p.Muted,{children:[x.KIND_LABEL[k.kind]," \xb7 safe: ",(0,x.limitText)(k)]}):null,S?(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:r,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[p.styles.input,{width:110,fontSize:22}]}),(0,C.jsx)(p.T,{size:18,children:"\xb0C"}),null===D?null:(0,C.jsx)(p.Badge,{kind:D?'ok':'red',label:D?'OK':'OUT OF RANGE'})]}):(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(p.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,C.jsx)(p.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===D?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p.Banner,{kind:"danger",title:S?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:h,onChangeText:m,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:p.styles.input})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:y,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{P(e,[{point:k,value:S?T:void 0,done:S?void 0:c,corrective:h,note:y,source:'typed'}]),r(''),u(void 0),m(''),j(''),v(`Saved: ${k.name}.`)}}),w?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:w}):null]})}function L({who:e}){const t=(0,o.useSafetyView)(e.mode).entries,n=(0,o.useSafetyView)(e.mode).allPoints,[s,i]=(0,d.useState)('7'),[l,r]=(0,d.useState)('all'),[c,u]=(0,d.useState)(!1),[m,y]=(0,d.useState)(''),j='staff'===e.mode,w=(0,d.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const o='today'===s?n.getTime():'all'===s?0:e.now.getTime()-864e5*Number(s);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=o)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,s,l,c,j,e.meId,e.now.getTime()]),v=Array.from(new Set(n.map(e=>e.kind))),k=e.now.toISOString().slice(0,10);return(0,C.jsxs)(f.Box,{testID:"haccp-history",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,C.jsx)(p.Chip,{label:t,selected:s===e,onPress:()=>i(e)},e))}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Chip,{label:"All checks",selected:'all'===l,onPress:()=>r('all')}),v.map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:l===e,onPress:()=>r(e)},e))]}),(0,C.jsx)(p.Toggle,{label:"Out of range only",value:c,onChange:u}),(0,C.jsx)(h.default,{testID:"haccp-count",children:(0,C.jsxs)(p.Muted,{children:[w.length," entr",1===w.length?'y':'ies',w.filter(e=>!e.ok).length?` \xb7 ${w.filter(e=>!e.ok).length} out of range`:'']})}),w.length?w.slice(0,200).map(e=>(0,C.jsx)($,{e:e},e.id)):(0,C.jsx)(p.Muted,{children:"No entries for these filters yet."}),j?null:(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!w.length,onPress:()=>y((0,f.downloadText)(`food-safety-log-${k}.csv`,(0,x.toCsv)(w,n))?`CSV downloaded: ${w.length} entries.`:'Downloads work in the web app.')}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!w.length,onPress:()=>y((0,f.printTable)('Food safety log (HACCP)',`${w.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,x.LOG_HEAD,(0,x.logRows)(w,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),m?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:m}):null]})}function $({e:e}){return(0,C.jsxs)(h.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,C.jsx)(p.T,{size:17,weight:"bold",colour:e.ok?b.colours.ok:b.colours.red,children:(0,x.fmtEntryValue)(e)})]}),(0,C.jsxs)(p.Row,{gap:6,children:[(0,C.jsx)(y.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,C.jsxs)(p.Muted,{style:{flex:1},children:[T(e.at)," ",S(e.at)," \xb7 ",e.initials??(0,x.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,C.jsxs)(p.T,{size:13,colour:b.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,C.jsxs)(p.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,C.jsx)(c.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function A({editable:e,mode:t}){const n=(0,o.useSafetyView)(t).points,[s,i]=(0,d.useState)('');return(0,C.jsxs)(f.Box,{testID:"haccp-limits",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,C.jsx)(p.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in CoverCharge for Head Chef.'}),n.map(t=>(0,C.jsx)(O,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,C.jsx)(z,{onAdded:e=>i(`Added ${e}.`)}):null,s?(0,C.jsx)(p.T,{size:14,colour:b.colours.ok,children:s}):null]})}function O({p:e,editable:n,onSaved:s}){const[o,i]=(0,d.useState)(null==e.min?'':String(e.min)),[l,r]=(0,d.useState)(null==e.max?'':String(e.max)),[c,u]=(0,d.useState)(e.due.join(', ')),y=(0,x.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),w=f&&(''===o||null!=I(o))&&(''===l||null!=I(l));return n?(0,C.jsxs)(h.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:b.colours.border},testID:`limit-${e.id}`,children:[(0,C.jsxs)(p.T,{weight:"medium",children:[e.name," ",(0,C.jsxs)(p.Muted,{children:["\xb7 ",x.KIND_LABEL[e.kind]]})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]}),(0,C.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:r,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[p.styles.input,{width:90}]})]}):null,(0,C.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:u,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,C.jsx)(p.Button,{small:!0,label:"Save",disabled:!w,onPress:()=>{m.useSafety.getState().setPoint(e.id,{min:''===o?void 0:I(o),max:''===l?void 0:I(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,C.jsx)(p.T,{size:13,colour:b.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,C.jsx)(p.T,{size:14,style:{flex:1},children:e.name}),(0,C.jsxs)(p.Muted,{children:[(0,x.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function z({onAdded:e}){const[n,s]=(0,d.useState)(''),[o,i]=(0,d.useState)('fridge');return(0,C.jsxs)(h.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsx)(p.T,{weight:"medium",children:"Add a check point"}),(0,C.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:Object.keys(x.KIND_LABEL).map(e=>(0,C.jsx)(p.Chip,{label:x.KIND_LABEL[e],selected:e===o,onPress:()=>i(e)},e))}),(0,C.jsx)(p.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,l.chefCanSee)(r.useOwner.getState().site,n),onPress:()=>{if(!(0,l.chefCanSee)(r.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};m.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function M({me:e,now:n,mode:s}){const i=(0,o.useSafetyView)(s).probes??[],c=(0,o.useSafetyView)(s).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,x]=(0,d.useState)(!1),[y,j]=(0,d.useState)(''),[w,v]=(0,d.useState)(''),[k,S]=(0,d.useState)(null),[T,I]=(0,d.useState)(''),D=c.find(e=>e.id===w);return(0,C.jsxs)(f.Box,{testID:"haccp-probes",children:[(0,C.jsx)(p.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,C.jsx)(p.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),i.length?i.map(e=>(0,C.jsxs)(h.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:b.colours.border},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(h.default,{style:{flex:1,gap:2},children:[(0,C.jsx)(p.T,{weight:"semibold",children:e.name}),(0,C.jsx)(p.Muted,{children:e.location})]}),(0,C.jsx)(p.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,C.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,C.jsx)(p.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(k===e.id?null:e.id)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>m.useSafety.getState().removeProbe(e.id)})]}),k===e.id?(0,C.jsxs)(h.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connect your probe"}),(0,C.jsxs)(p.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,C.jsx)(p.T,{size:14,children:"2. Keep this device near the probe."}),(0,C.jsx)(p.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,C.jsx)(h.default,{testID:"probes-empty",children:(0,C.jsx)(p.Muted,{children:"No probes yet."})}),T?(0,C.jsx)(h.default,{testID:"probe-msg",children:(0,C.jsx)(p.Banner,{kind:"info",children:T})}):null,u?(0,C.jsxs)(h.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.gold},children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:y,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[p.styles.input,{minWidth:0}]}),(0,C.jsx)(p.Muted,{children:"Where is it?"}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:c.map(e=>(0,C.jsx)(p.Chip,{label:e.name,selected:w===e.id,onPress:()=>v(e.id)},e.id))}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(p.Button,{label:"Save probe",disabled:!y.trim()||!D,onPress:()=>{y.trim()&&D&&('chef'!==s||(0,l.chefCanSee)(r.useOwner.getState().site,D))&&(m.useSafety.getState().addProbe({name:y.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${y.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),v(''),x(!1))}}),(0,C.jsx)(p.Button,{kind:"ghost",label:"Cancel",onPress:()=>x(!1)})]})]}):(0,C.jsx)(p.Button,{kind:"secondary",label:"Add probe",onPress:()=>{x(!0),I('')}}),(0,C.jsx)(p.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1207,[812,1208,779,1209,1130,820,876,17,319,385,85,777,1003,1004,804,884,889,1210,1213,1216,1218,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VOICE_DISPLAY_VENUES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ASSISTANT_UI",{enumerable:!0,get:function(){return t}}),e.voiceDisplayOn=function(n){return!1},Object.defineProperty(e,"MIC_OUTSIDE_DISPLAY",{enumerable:!0,get:function(){return u}});r(d[0]),r(d[1]),r(d[2]);const n=[],t=!1;const u=!1},1208,[880,805,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1209,[17,1003,876,820]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.speechRecognition=function(){return'undefined'==typeof window?null:(0,n.speechRecognizer)()},r(d[0]);var n=r(d[1])},1210,[219,1211]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"desktopStt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"desktopSttState",{enumerable:!0,get:function(){return u}}),_e.warmDesktopStt=function(){o()&&l()},Object.defineProperty(_e,"cleanHeard",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"tabletWithoutMic",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"canRecord",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canListen",{enumerable:!0,get:function(){return w}}),_e.micPermission=b,Object.defineProperty(_e,"RATE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PRE_ROLL_MS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"HANG_MS",{enumerable:!0,get:function(){return A}}),_e.releaseMic=O,Object.defineProperty(_e,"echoWanted",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"micConstraints",{enumerable:!0,get:function(){return j}}),_e.warmMic=async function(){try{if(o()||!y())return;if(!S&&'granted'!==await b())return;if(await D(),C){C.armedUntil=Date.now()+1500;try{C.ctx.resume?.()}catch{}}x()}catch{}},_e.disarmMic=function(){C&&!C.rec&&(C.armedUntil=0,C.ring=[],C.ringLen=0)},_e.askMic=async function(){try{return await D(),x(),!0}catch{return!1}},_e.wavOf=L,Object.defineProperty(_e,"MAX_CLIP_MS",{enumerable:!0,get:function(){return _}}),_e.listen=B,Object.defineProperty(_e,"CloudRecognition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"speechRecognizer",{enumerable:!0,get:function(){return N}}),_e.levelMeter=async function(e){const t=n()?.navigator?.mediaDevices,r=n()?.AudioContext||n()?.webkitAudioContext;if(!t?.getUserMedia||!r)return()=>{};let o,i,a=0,c=!1;try{if(o=await t.getUserMedia({audio:!0}),c)return o.getTracks().forEach(e=>e.stop()),()=>{};i=new r;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=512,s.connect(u);const l=new Uint8Array(u.fftSize),d=()=>{u.getByteTimeDomainData(l);let t=0;for(let e=0;e{}}return()=>{c=!0;try{n().cancelAnimationFrame(a)}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}}},_e.yesNo=function(e){const t=e.toLowerCase().trim().replace(/[.!,]/g,'');return/^(yes|yeah|yep|yup|aye|confirm|confirmed|do it|go ahead|correct|that's right|ok|okay|yes please)\b/.test(t)?'yes':/^(no|nope|cancel|stop|don't|do not|wrong|never mind)\b/.test(t)?'no':null},Object.defineProperty(_e,"buzz",{enumerable:!0,get:function(){return W}});var e=_r(_d[0]),t=_r(_d[1]);const n=()=>'undefined'==typeof window?void 0:window,r=()=>n()?.ccDesktop,o=()=>!!r()?.stt&&!!r()?.sttWorker;let i=null,a=0;const c=new Map;let s='cold';const u=()=>s;function l(){if(i)return i;const e=n()?.Worker,t=r()?.sttWorker;return e&&t?(i=new e(t,{type:'module'}),s='loading',i.onmessage=e=>{const t=e.data??{};if(t.ready)return void(s='ready');t.failed&&(s='failed');const n=c.get(t.id);n&&(c.delete(t.id),n(t))},i.onerror=()=>{s='failed',c.forEach(e=>e({error:'stt-failed'})),c.clear()},i.postMessage({warm:!0}),i):null}const d=e=>e.replace(/\[[^\]]*\]|\([^)]*\)/g,' ').replace(/\s+/g,' ').trim();function f(e,t){let o,i,s,u,f=!1,p=!1;const y=[];let w=16e3;const b=()=>{try{s?.disconnect(),u?.disconnect()}catch{}try{o?.getTracks().forEach(e=>e.stop())}catch{}try{i?.close()}catch{}if(p)return;const n=y.reduce((e,t)=>e+t.length,0);if(n<.35*w)return void t('');const r=new Float32Array(n);let f=0;for(const e of y)r.set(e,f),f+=e.length;const b=16e3===w?r:h(r,w,16e3),v=l();if(!v)return void t('','stt-failed');e('Turning speech into text on this Mac\u2026');const M=++a;c.set(M,e=>t(d(e.text??''),e.error)),v.postMessage({id:M,audio:b},[b.buffer])};return(async()=>{try{if(r()?.askMic){if(!await r().askMic())return void t('','not-allowed')}if(o=await n().navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),f)return void b();const e=n().AudioContext||n().webkitAudioContext;try{i=new e({sampleRate:16e3})}catch{i=new e}w=i.sampleRate,u=i.createMediaStreamSource(o),s=i.createScriptProcessor(4096,1,1),s.onaudioprocess=e=>{f||y.push(new Float32Array(e.inputBuffer.getChannelData(0)))},u.connect(s),s.connect(i.destination),l()}catch(e){t('','NotAllowedError'===e?.name?'not-allowed':'audio-capture')}})(),{stop:()=>{f||(f=!0,b())},abort:()=>{p=!0,f=!0,b()}}}function h(e,t,n){const r=Math.round(e.length*n/t),o=new Float32Array(r),i=t/n;for(let t=0;t{const e=String(n()?.navigator?.userAgent??'');return/CoverChargeTablet\//.test(e)&&!/CoverChargeTablet\/[\d.]+ mic/.test(e)},y=()=>!p()&&!(!n()?.MediaRecorder||!n()?.navigator?.mediaDevices?.getUserMedia),w=()=>o()||y();async function b(){try{const e=n()?.navigator?.permissions?.query;if(!e)return'unknown';const t=await Promise.race([n().navigator.permissions.query({name:'microphone'}),new Promise(e=>setTimeout(()=>e(null),1500))]);return'granted'===t?.state||'denied'===t?.state||'prompt'===t?.state?t.state:'unknown'}catch{return'unknown'}}const v=16e3,M=500,A=450;let P,S=null,T=!1,k=!1,C=null;function U(){const e=C;if(C=null,e){try{e.node.disconnect(),e.src.disconnect()}catch{}try{e.ctx.close()}catch{}e.ring=[],e.rec=null}}function O(){clearTimeout(P),U();try{S?.getTracks().forEach(e=>e.stop())}catch{}S=null}const x=()=>{clearTimeout(P),P=setTimeout(O,/iPhone|iPad|iPod|Macintosh/.test(String(n()?.navigator?.userAgent??''))&&!r()?.mac?6e5:6e4)},R=()=>!1,j=(e=R())=>({audio:{channelCount:{ideal:1},sampleRate:{ideal:v},sampleSize:{ideal:16},echoCancellation:e,noiseSuppression:!0,autoGainControl:!0}});async function D(){clearTimeout(P);const e=R();if(S&&T===e&&S.getAudioTracks().some(e=>'live'===e.readyState))return S;if(S&&O(),S=await n().navigator.mediaDevices.getUserMedia(j(e)),T=e,!k){k=!0;try{n().document.addEventListener('visibilitychange',()=>{'hidden'===n().document.visibilityState&&O()})}catch{}}return E(S),S}function E(e){U();try{const t=n().AudioContext||n().webkitAudioContext;if(!t)return;let r;try{r=new t({sampleRate:v})}catch{r=new t}const o=r.createMediaStreamSource(e),i=r.createScriptProcessor(2048,1,1),a={ctx:r,node:i,src:o,rate:r.sampleRate,ring:[],ringLen:0,rec:null,frames:0,armedUntil:0,level:()=>{}},c=Math.round(.5*a.rate);i.onaudioprocess=e=>{const t=new Float32Array(e.inputBuffer.getChannelData(0));if(a.frames+=t.length,a.rec&&a.rec.push(t),!a.rec&&Date.now()>a.armedUntil)return a.ring=[],void(a.ringLen=0);for(a.ring.push(t),a.ringLen+=t.length;a.ring.length>1&&a.ringLen-a.ring[0].length>=c;)a.ringLen-=a.ring[0].length,a.ring.shift();let n=0;for(let e=0;ee+t.length,0),r=new Float32Array(n);let o=0;for(const t of e)r.set(t,o),o+=t.length;const i=t===v?r:h(r,t,v),a=new ArrayBuffer(44+2*i.length),c=new DataView(a),s=(e,t)=>{for(let n=0;n{clearTimeout(c),clearTimeout(s),S&&(S.rec=null,S.level=()=>{}),x()},k=(e,t,n)=>{h||f||(h=!0,o(e,t,n))};let U=!1;const O=async()=>{if(U)return;U=!0;const n=b,o=S?S.frames-P:0;if(T(),f)return;const i=Date.now()-y,a=!!n&&n.length>0&&o/M*1e3>.6*i?L(n,M):new Blob(w,{type:(p?.mimeType||w[0]?.type||'audio/webm').split(';')[0]});if(i<350||a.size<500)return void k('');r('Turning speech into text\u2026');const c=await(0,e.transcribe)(t,a);c.ok?k(c.text.trim(),void 0,{receipt:c.receipt}):k('',c.reason,{message:c.text})};(async()=>{try{const e=await D();if(d)return T(),void k('');if(S=C,S){try{S.ctx.resume?.()}catch{}b=[...S.ring],M=S.rate,P=S.frames-S.ringLen,S.rec=b,S.level=e=>{i?.(e),a&&!d&&(e>.12?(u=!0,l=0):u&&e<.05&&(l=l||Date.now(),Date.now()-l>1500&&j()))}}const t=F();p=new(n().MediaRecorder)(e,t?{mimeType:t,audioBitsPerSecond:48e3}:void 0),p.ondataavailable=e=>{e.data?.size&&w.push(e.data)},p.onstop=()=>{O()},p.onerror=()=>{b?.length?O():(T(),k('','audio-capture'))},p.start(),y=Date.now(),c=setTimeout(()=>{r('That\u2019s the 30-second limit. Sending now\u2026'),R()},_)}catch(e){T(),k('','NotAllowedError'===e?.name||'SecurityError'===e?.name?'not-allowed':'audio-capture')}})();const R=()=>{try{p&&'inactive'!==p.state?p.stop():O()}catch{O()}},j=()=>{d||(d=!0,p&&(s=setTimeout(R,a?0:A)))};return{stop:j,abort:()=>{f=!0,d=!0,clearTimeout(s);try{p&&'inactive'!==p.state&&p.stop()}catch{}T()}}}function B(e,t,n="owner",r,i=!1){return o()?f(e,t):y()?z(n,e,t,r,i):null}class I{lang='en-GB';interimResults=!1;continuous=!1;maxAlternatives=1;onresult=null;onerror=null;onend=null;l=null;start(){const e='customer'===t.APP_VARIANT?'owner':t.APP_VARIANT;if(this.l=B(()=>{},(e,t)=>{if(this.l=null,t)this.onerror?.({error:t});else if(e){const t=Object.assign([{transcript:e,confidence:1}],{isFinal:!0});this.onresult?.({resultIndex:0,results:[t]})}this.onend?.()},e,void 0,!0),!this.l)throw new Error('not-supported')}stop(){this.l?.stop()}abort(){const e=this.l;this.l=null,e?.abort(),e&&this.onend?.()}}const N=()=>w()?I:null;const W=(e=30)=>{try{n()?.navigator?.vibrate?.(e)}catch{}}},1211,[1212,856]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOON_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"setVenueWords",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"getVenueWords",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setSessionMender",{enumerable:!0,get:function(){return n.setSessionMender}}),e.askServer=async function n(s,u,p,y,f=!0){try{const b=(0,t.getSupabase)().functions.invoke(o,{body:{app:s,text:u,tools:p,...y?{receipt:y,spoken:!0,vocab:c}:{}}}),k=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),1e4)),{data:w,error:v}=await Promise.race([b,k]);return f&&'identity'===w?.reason&&await l()?n(s,u,p,y,!1):v||!w||!0!==w.ready||w.busy?{kind:'soon'}:w.call?.name?{kind:'call',name:String(w.call.name),args:w.call.args??{}}:'string'==typeof w.text&&w.text.trim()?{kind:'text',text:w.text.trim()}:{kind:'soon'}}catch{return{kind:'soon'}}},e.transcribe=async function n(o,s,u=8e3,p=!0){try{const f=/mp4|m4a|aac/.test(s.type)?'m4a':/ogg/.test(s.type)?'ogg':/wav/.test(s.type)?'wav':'webm',b=new FormData;b.append('app',o),c.length&&b.append('keyterms',JSON.stringify(c)),b.append('file',s,`speech.${f}`);const k=(0,t.getSupabase)().functions.invoke(y,{body:b}),w=new Promise(t=>setTimeout(()=>t({data:null,error:new Error('timeout')}),u)),{data:v,error:x}=await Promise.race([k,w]);return x?{ok:!1,reason:'timeout'===String(x?.message)?'timeout':'offline'}:!0===v?.ok?{ok:!0,text:String(v.text??''),receipt:'string'==typeof v.receipt?v.receipt:void 0}:p&&'identity'===v?.reason&&await l()?n(o,s,u,!1):{ok:!1,reason:String(v?.reason??'busy'),text:'string'==typeof v?.text?v.text:void 0}}catch{return{ok:!1,reason:'offline'}}};var t=r(d[0]),n=r(d[1]);const o='voice-assistant',s='I couldn\u2019t work that one out just now. I can do the everyday things, for example';let c=[];const u=t=>{c=t.slice(0,100)},p=()=>c,l=n.mendSession;const y='voice-transcribe'},1212,[928,903]); +__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.saveEntry=z,_e.ProgressRing=_,_e.Keypad=E,_e.RecordPanel=M,_e.TodayView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points,o=(0,r.useSafetyView)(e.mode).entries,[s,n]=(0,d.useState)('all'),[i,l]=(0,d.useState)(null),[a,c]=(0,d.useState)(''),y=(0,d.useMemo)(()=>(0,b.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,b.sectionOf)(e.point)===s),x=e=>y.filter(t=>t.status===e).length;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-today",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.Row,{gap:16,children:[(0,T.jsx)(_,{done:x('done'),total:y.length}),(0,T.jsxs)(h.default,{style:{flex:1,gap:6},children:[(0,T.jsx)(p.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,T.jsx)(p.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(h.default,{testID:"today-overdue",children:(0,T.jsx)(p.Badge,{kind:x('overdue')?'red':'neutral',label:`${x('overdue')} overdue`})}),(0,T.jsx)(h.default,{testID:"today-due",children:(0,T.jsx)(p.Badge,{kind:x('due')?'amber':'neutral',label:`${x('due')} due now`})}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${x('upcoming')} later`})]}),(0,T.jsx)(p.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),b.SECTIONS.map(e=>(0,T.jsx)(p.Chip,{label:b.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),a?(0,T.jsx)(h.default,{testID:"today-msg",children:(0,T.jsx)(p.Banner,{kind:"success",children:a})}):null,b.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,T.jsxs)(k.Box,{testID:`slot-${t}`,children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:[b.SLOT_LABEL[t]," ",(0,T.jsxs)(p.Muted,{children:["\xb7 ",b.SLOT_HINT[t]]})]}),(0,T.jsx)(p.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,T.jsxs)(h.default,{style:{gap:8},children:[(0,T.jsxs)(u.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${W[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{c(''),l(i===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?w.colours.red:'due'===t.status?w.colours.amber:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2}),children:[(0,T.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:N[t.status],backgroundColor:'done'===t.status?t.entry?.ok?w.colours.ok:w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':N[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,T.jsxs)(h.default,{style:{width:'100%',gap:2},children:[(0,T.jsx)(p.T,{weight:"medium",children:t.point.name}),(0,T.jsxs)(p.Muted,{children:[t.due," \xb7 ",b.SECTION_LABEL[(0,b.sectionOf)(t.point)],(0,b.isTempKind)(t.point.kind)?` \xb7 ${(0,b.limitText)(t.point)}`:'']}),t.entry?(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(f.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,T.jsxs)(p.Muted,{children:[(0,b.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,b.initialsOf)(t.entry.by)," ",$(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:N[t.status],children:W[t.status]})]}),i===t.key?(0,T.jsx)(M,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),c(e)}}):null]},t.key))]},t):null}),y.length?null:(0,T.jsxs)(p.Muted,{children:["No scheduled checks",'all'===s?'':` in ${b.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).probes??[],[n,i]=(0,d.useState)(null),[l,a]=(0,d.useState)('');return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,T.jsx)(p.Banner,{kind:"success",children:l}):null,(0,T.jsx)(p.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const r=(0,b.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,T.jsxs)(h.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===r.rag?w.colours.border:v[r.rag],backgroundColor:w.colours.surface},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",children:t.name}),(0,T.jsxs)(p.Muted,{children:[b.KIND_LABEL[t.kind]," \xb7 safe ",(0,b.limitText)(t)]})]}),(0,T.jsxs)(h.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,T.jsx)(h.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:v[r.rag]}}),(0,T.jsx)(p.T,{size:13,weight:"semibold",colour:v[r.rag],children:'amber'===r.rag?r.why:B[r.rag]})]})]}),r.latest?(0,T.jsxs)(p.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:v[r.rag],children:[r.latest.value,"\xb0C"]}),(0,T.jsxs)(p.Muted,{style:{paddingBottom:8},children:[C(r.latest.at)," ",$(r.latest.at)," \xb7 ",r.latest.initials??(0,b.initialsOf)(r.latest.by)]})]}):(0,T.jsx)(p.T,{size:20,colour:w.colours.muted,children:"\u2014 \xb0C"}),(0,T.jsx)(V,{p:t,history:r.history}),l?(0,T.jsxs)(p.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,T.jsx)(p.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{a(''),i(n===t.id?null:t.id)}}),n===t.id?(0,T.jsx)(M,{who:e,point:t,onCancel:()=>i(null),onDone:e=>{i(null),a(e)}}):null]},t.id)})}),(0,T.jsx)(p.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).diary??[],o=(0,r.useSafetyView)(e.mode).daySigns??[],s=(0,r.useSafetyView)(e.mode).entries,n=(0,b.ymdLocal)(e.now),[l,a]=(0,d.useState)(n),[c,u]=(0,d.useState)('Note'),[y,x]=(0,d.useState)(''),[j,S]=(0,d.useState)(''),D=Array.from({length:7},(t,o)=>(0,b.ymdLocal)(O(e.now,-o))),C=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),B=s.filter(e=>(0,b.ymdLocal)(new Date(e.at))===l),L='staff'!==e.mode;return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-diary",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:D.map(e=>(0,T.jsx)(p.Chip,{label:e===n?'Today':R(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>a(e)},e))}),(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:R(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,T.jsxs)(p.Muted,{children:[B.length," check",1===B.length?'':'s'," recorded",B.filter(e=>!e.ok).length?` \xb7 ${B.filter(e=>!e.ok).length} out of range or not done`:'']}),C.length?C.map(e=>(0,T.jsxs)(h.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border},children:[(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,T.jsx)(p.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,T.jsxs)(p.Muted,{children:[$(e.at)," \xb7 ",e.by]})]}),(0,T.jsx)(p.T,{size:14,children:e.text}),e.action?(0,T.jsxs)(p.T,{size:13,colour:w.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,T.jsx)(p.Muted,{children:"Nothing written for this day yet."})]}),(0,T.jsxs)(k.Box,{testID:"diary-add",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Add to the diary"}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:A.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:c===e,onPress:()=>u(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:x,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:70}]}),'Problem'===c?(0,T.jsx)(i.TextInput,{accessibilityLabel:"What did you do about it",value:j,onChangeText:S,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:p.styles.input}):null,(0,T.jsx)(p.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&j.trim().length<3,onPress:()=>{m.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:I(e.me),byId:e.meId,kind:c,text:y.trim(),action:j.trim()||void 0}),x(''),S('')}})]}),(0,T.jsxs)(k.Box,{testID:"diary-daysign",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,T.jsxs)(p.T,{size:14,colour:w.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",$(v.at)]})]}):L?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,T.jsx)(p.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==n,onPress:()=>m.useSafety.getState().signDay({date:l,by:I(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==n?(0,T.jsx)(p.Muted,{children:"Only today can be signed."}):null]}):(0,T.jsx)(p.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,r.useSafetyView)(e.mode).weekly??[],o=(0,r.useSafetyView)(e.mode).entries,s=(0,r.useSafetyView)(e.mode).daySigns??[],n=(0,b.weekStart)(e.now),l=(0,b.weekStart)(O(R(n),-7)),[a,c]=(0,d.useState)(n),[u,y]=(0,d.useState)(b.WEEKLY_QUESTIONS.map(()=>{})),[x,j]=(0,d.useState)(''),[S,D]=(0,d.useState)(''),v=R(a).getTime(),B=O(R(a),7).getTime(),L=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:L.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=R(e.date).getTime();return t>=v&&te.week===a),E='staff'!==e.mode,P=u.every(e=>void 0!==e),M=u.some(e=>!1===e);return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Chip,{label:"This week",selected:a===n,onPress:()=>c(n)}),(0,T.jsx)(p.Chip,{label:"Last week",selected:a===l,onPress:()=>c(l)})]}),(0,T.jsxs)(k.Box,{children:[(0,T.jsxs)(p.T,{weight:"semibold",size:17,children:["Week of ",R(a).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,T.jsx)(p.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,T.jsx)(p.Badge,{kind:z.actions(0,T.jsxs)(p.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,T.jsxs)(p.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,T.jsxs)(k.Box,{testID:"weekly-form",children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Weekly review"}),b.WEEKLY_QUESTIONS.map((e,t)=>(0,T.jsxs)(h.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:w.colours.border},children:[(0,T.jsx)(p.T,{size:14,children:e}),(0,T.jsxs)(p.Row,{gap:6,children:[(0,T.jsx)(p.Chip,{label:"Yes",selected:!0===u[t],onPress:()=>y(u.map((e,o)=>o===t||e))}),(0,T.jsx)(p.Chip,{label:"No",selected:!1===u[t],onPress:()=>y(u.map((e,o)=>o!==t&&e))})]})]},e)),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Weekly note",value:x,onChangeText:j,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[p.styles.input,{minHeight:60},M&&!x.trim()&&{borderColor:w.colours.red}]}),(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signing as ",I(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,T.jsx)(p.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&x.trim().length<3,onPress:()=>{m.useSafety.getState().signWeek({week:a,by:I(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:u.map(Boolean),note:x.trim(),summary:z}),D('Week signed off.')}}),S?(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:S}):null]}):(0,T.jsx)(k.Box,{children:(0,T.jsx)(p.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==a).length?(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==a).slice(0,8).map(e=>(0,T.jsxs)(p.Muted,{children:["Week of ",R(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",C(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,D.venueInfo)().address}){const o=(0,r.useSafetyView)(e.mode).entries,n=(0,r.useSafetyView)(e.mode).allPoints,l=(0,r.useSafetyView)(e.mode).diary??[],a=(0,r.useSafetyView)(e.mode).daySigns??[],c=(0,r.useSafetyView)(e.mode).weekly??[],[u,y]=(0,d.useState)('week'),x=(0,b.ymdLocal)(e.now),[f,m]=(0,d.useState)((0,b.ymdLocal)(O(e.now,-13))),[S,v]=(0,d.useState)(x),[B,L]=(0,d.useState)(''),z=(0,b.weekStart)(e.now),[_,E]='week'===u?[z,x]:'lastweek'===u?[(0,b.ymdLocal)(O(R(z),-7)),(0,b.ymdLocal)(O(R(z),-1))]:'7'===u?[(0,b.ymdLocal)(O(e.now,-6)),x]:'28'===u?[(0,b.ymdLocal)(O(e.now,-27)),x]:[f,S],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=o.filter(e=>M((0,b.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=a.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,b.ymdLocal)(O(R(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>n.find(t=>t.id===e.pointId),F=b.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,b.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${R(_).toLocaleDateString('en-GB')} to ${R(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),$(e.at),Y(e)?b.SECTION_LABEL[(0,b.sectionOf)(Y(e))]:'',e.name,(0,b.fmtEntryValue)(e),Y(e)?(0,b.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,b.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,T.jsxs)(h.default,{style:{gap:12},testID:"haccp-report",children:[(0,T.jsxs)(k.Box,{children:[(0,T.jsx)(p.T,{weight:"semibold",size:17,children:"EHO report"}),(0,T.jsx)(p.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,T.jsx)(p.Chip,{label:t,selected:u===e,onPress:()=>y(e)},e))}),'custom'===u?(0,T.jsxs)(p.Row,{gap:8,children:[(0,T.jsx)(i.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,s.slashBox)(f,m),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,s.slashBox)(S,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,T.jsx)(h.default,{testID:"report-period",children:(0,T.jsx)(p.Muted,{children:H})}):(0,T.jsx)(p.T,{size:13,colour:w.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,T.jsxs)(k.Box,{testID:"report-summary",children:[(0,T.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,T.jsx)(p.Badge,{kind:"gold",label:`${N.length} checks`}),(0,T.jsx)(p.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,T.jsx)(p.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,T.jsx)(p.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(p.T,{size:14,children:b.SECTION_LABEL[e.s]}),(0,T.jsxs)(p.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,T.jsxs)(h.default,{style:{gap:4},children:[(0,T.jsx)(p.T,{weight:"semibold",colour:w.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,T.jsxs)(p.Muted,{children:[C(e.at)," ",$(e.at)," \xb7 ",e.name," ",(0,b.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,T.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,T.jsx)(p.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${I(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By CookSafe section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${b.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.name}: ${(0,b.fmtEntryValue)(e)} (safe ${Y(e)?(0,b.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${$(e.at)} ${e.name}: ${(0,b.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,b.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')} ${$(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${R(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${$(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${R(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),b.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,k.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,j.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');L(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,T.jsx)(p.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>L((0,k.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,T.jsx)(p.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>L((0,k.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),B?(0,T.jsx)(h.default,{testID:"report-msg",children:(0,T.jsx)(p.T,{size:14,colour:w.colours.ok,children:B})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=e(_r(_d[9])),u=e(_r(_d[10])),h=e(_r(_d[11])),y=_r(_d[12]),x=e(y),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]),D=_r(_d[21]),T=_r(_d[22]);const $=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),C=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),I=e=>e.replace(' (example)',''),v={ok:w.colours.ok,amber:w.colours.amber,red:w.colours.red,none:w.colours.muted},B={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},L=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},R=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},O=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function z(e,t,o){if('chef'===e.mode&&!(0,l.chefCanSee)(a.useOwner.getState().site,t))return;const s=(0,b.isTempKind)(t.kind)?(0,b.inRange)(t,o.value):!!o.done;m.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:I(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,b.initialsOf)(e.me)}])}function _({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,T.jsxs)(h.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,T.jsxs)(x.default,{width:o,height:o,style:{position:'absolute'},children:[(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,T.jsx)(y.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?w.colours.ok:w.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,T.jsxs)(p.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,T.jsxs)(p.Muted,{children:[e," of ",t]})]})}function E({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,T.jsxs)(h.default,{style:{gap:8},testID:"keypad",children:[(0,T.jsx)(p.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:w.colours.border,backgroundColor:e?w.colours.goldTint:w.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,T.jsx)(p.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:w.colours.border,alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,children:"\u232b Delete"})})]})}const P=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function M({who:e,point:s,onDone:r,onCancel:l}){const a=(0,b.isTempKind)(s.kind),[y,x]=(0,d.useState)(''),[m,j]=(0,d.useState)(),[D,$]=(0,d.useState)(''),[C,v]=(0,d.useState)(''),[B,R]=(0,d.useState)(),[O,_]=(0,d.useState)(!1),[M,N]=(0,d.useState)(''),[W,V]=(0,d.useState)(!1),A=(0,d.useRef)(null),G=L(y),Y=a?null==G?null:(0,b.inRange)(s,G):void 0===m?null:m,F=null!==Y&&(Y||D.trim().length>2);return(0,T.jsxs)(h.default,{testID:`record-${s.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===Y?w.colours.red:w.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.default,{style:{flex:1},children:[(0,T.jsx)(p.T,{weight:"semibold",size:16,children:s.name}),(0,T.jsxs)(p.Muted,{children:[b.SECTION_LABEL[(0,b.sectionOf)(s)]," \xb7 safe: ",(0,b.limitText)(s)]})]}),(0,T.jsx)(n.GoldClose,{testID:"check-close",onPress:l,style:{marginRight:-6}})]}),a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p.Row,{style:{justifyContent:'center',gap:12},children:[(0,T.jsx)(h.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==Y?w.colours.border:Y?w.colours.ok:w.colours.red,alignItems:'center'},children:(0,T.jsxs)(p.T,{size:40,weight:"bold",colour:null==Y?w.colours.text:Y?w.colours.ok:w.colours.red,children:[y||'\u2014',(0,T.jsx)(p.T,{size:22,children:" \xb0C"})]})}),o.MIC_OUTSIDE_DISPLAY?(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,S.speechRecognition)();if(!e)return void N("Voice isn't available in this browser. Use the keypad.");if(W)return void A.current?.stop();const t=new e;A.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,b.spokenNumber)(t);N(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(x(String(o)),_(!0))},t.onerror=()=>N("Didn't catch that. Try again or use the keypad."),t.onend=()=>V(!1);try{t.start(),V(!0)}catch{N("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:W?w.colours.gold:'transparent'},children:(0,T.jsx)(p.T,{size:26,children:W?'\u25a0':'\ud83c\udfa4'})}):null]}),null!=Y?(0,T.jsx)(p.Row,{style:{justifyContent:'center'},children:(0,T.jsx)(p.Badge,{kind:Y?'ok':'red',label:Y?'OK':'OUT OF RANGE'})}):null,M?(0,T.jsx)(p.Muted,{center:!0,children:M}):null,(0,T.jsx)(E,{value:y,onChange:e=>{x(e),_(!1)}})]}):(0,T.jsxs)(p.Row,{gap:10,children:[(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>j(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:!0===m?w.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!0===m?'#0B0B0B':w.colours.gold,children:"\u2713 Done"})}),(0,T.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>j(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:w.colours.red,backgroundColor:!1===m?w.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,T.jsx)(p.T,{size:18,weight:"bold",colour:!1===m?'#0B0B0B':w.colours.red,children:"\u2715 Not done"})})]}),!1===Y?(0,T.jsxs)(h.default,{testID:"corrective",style:{gap:8},children:[(0,T.jsx)(p.Banner,{kind:"danger",title:a?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,T.jsx)(p.Row,{wrap:!0,gap:6,children:P.map(e=>(0,T.jsx)(p.Chip,{label:e,selected:D===e,onPress:()=>$(e)},e))}),(0,T.jsx)(i.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:D,onChangeText:$,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[p.styles.input,!D.trim()&&{borderColor:w.colours.red}]}),(0,T.jsx)(p.Row,{gap:8,children:B?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c.default,{source:{uri:B},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,T.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>R(void 0)})]}):(0,T.jsx)(p.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,k.pickImageDataUrl)(480,!0);e&&R(e)}})})]}):null,(0,T.jsx)(i.TextInput,{accessibilityLabel:"Note (optional)",value:C,onChangeText:v,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:p.styles.input}),(0,T.jsxs)(p.Row,{gap:8,style:{alignItems:'center'},children:[(0,T.jsx)(f.StaffAvatar,{id:e.meId,size:30}),(0,T.jsxs)(p.Muted,{style:{flex:1},children:["Signed ",(0,b.initialsOf)(e.me)," \xb7 ",I(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,T.jsx)(p.Button,{label:"Sign and save",testID:"record-save",disabled:!F,onPress:()=>{z(e,s,{value:a?G:void 0,done:a?void 0:m,corrective:Y?void 0:D,note:C,photo:Y?void 0:B,source:O?'voice':'typed'}),r(`Saved: ${s.name}${a?` ${G}\xb0C`:m?' done':' not done'}, signed ${(0,b.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const N={done:w.colours.ok,overdue:w.colours.red,due:w.colours.amber,upcoming:w.colours.muted},W={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function V({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,T.jsx)(p.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,T.jsxs)(x.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,T.jsx)(y.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:w.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,T.jsx)(y.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:w.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,T.jsx)(y.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?w.colours.ok:w.colours.red},e.id))]})}const A=['Note','Problem','Extra check','Delivery']},1213,[813,1208,1033,779,812,1209,820,876,17,319,385,85,780,777,884,1003,1004,1214,804,889,1210,1215,8]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1214,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1215,[816,876,805]); +__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.useMaySendInspectorLog=function(e){const t=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,p.maySendInspectorLog)(e.mode,t)},_e.emailInspector=j,_e.InspectorView=function({who:e}){const x=(0,b.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...x,points:x.allPoints}),[x]),v=(0,c.useSafety)(e=>e.inspectorSends)??S,C=(0,l.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,p.maySendInspectorLog)(e.mode,C),R=(0,h.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,p.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,E]=(0,t.useState)(''),[N,B]=(0,t.useState)(!0),[O,Y]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[_,F]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(r.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=N?k:(0,p.parseDmy)(O)??'',G=N?R:(0,p.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,p.inspectorNameProblem)($),K=(0,p.inspectorEmailProblem)(P),X=q?(0,p.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,p.senderRoleWords)(e.mode,C),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,p.buildInspectorCsv)({log:{...D,inspectorSends:v},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`,s=await j(P,$,t.fileName,t.csv,n)??await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,p.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(c.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,p.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(r.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(r.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(r.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),_&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:J})}):null,(0,I.jsx)(r.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{E(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),_&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(f.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(r.Chip,{label:"All history",testID:"inspector-all",selected:N,accessibilityLabel:"All history",onPress:()=>{B(!0),U(!1)}}),(0,I.jsx)(r.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!N,accessibilityLabel:"Choose dates",onPress:()=>{B(!1),U(!1),O||Y((0,p.dmy)(k)),A||W((0,p.dmy)(R))}})]}),N?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(r.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:O,onChangeText:e=>{Y((0,n.slashDate)(e,O)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(r.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(r.Muted,{center:!0,testID:"inspector-range",children:[(0,p.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.T,{size:14,colour:y.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(r.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:y.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,p.confirmQuestion)(P,Q,G)}),p.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(r.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(r.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,p.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(r.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(r.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{F(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(r.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(r.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,p.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(f.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(r.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),v.length?v.slice(0,20).map(e=>(0,I.jsxs)(r.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,p.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(r.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=_r(d[0]),n=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]),b=_r(d[13]),x=_r(d[14]),I=_r(d[15]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const r=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[r]}))return await s.share({files:[r],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,f.downloadText)(e,t)?'downloaded':null}async function j(e,t,n,s,o){if(!p.INSPECTOR_EMAIL.ready)return null;try{return(await(0,x.getSupabase)().functions.invoke('inspector-log-email',{body:{to:e.trim(),name:t.trim(),subject:o,fileName:n,csv:s}})).error?null:'emailed'}catch{return null}}const S=[]},1216,[17,1033,362,219,85,777,876,1003,1215,1004,1217,804,889,1209,928,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return o}}),_e.inspectorEmailProblem=r,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return a}}),_e.inspectorNameProblem=s,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return l}}),_e.rangeWords=d,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${d(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',y(t.at),u(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,l(e.date),u(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',l(e.date),u(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${l(t.week)})`,y(t.at),u(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${l(t.week)})`,y(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',y(e.at),u(e.at),'Management','','',`${l(e.from)} to ${l(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${d(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,h,...r].map(e=>e.map(f).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const t=s(e.inspectorName);if(t)return{ok:!1,why:t};const n=r(e.inspectorEmail);return n?{ok:!1,why:n}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||o.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:o.why}};var e=_r(_d[0]),t=_r(_d[1]);const o={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},n=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function r(e){const t=(e??'').trim();return t?t.length>254||!n.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const a=e=>''===r(e);function s(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const i=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},l=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},c=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function d(e,t){const o=i(e),n=i(t),r=e=>`${e.getDate()} ${c[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${c[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function m(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),s=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(i(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:s,daySigns:l,weekly:c,records:a.length+s.length+l.length+c.length}}const f=e=>(0,t.csvCell)(e),u=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),y=e=>new Date(e).toLocaleDateString('en-GB'),h=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1217,[1004,991]); +__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.CookSafeRecords=function({who:e,rid:s}){const[i,o]=(0,t.useState)('delivery'),c=(0,r.useCookSafe)(e=>e.records)??p,d=(e,t)=>({id:e,label:t}),u=[d('delivery','Deliveries'),d('reheat','Reheating 82\xb0C'),d('offsite','Off-site'),d('cleaning','Cleaning schedule'),d('pest','Pest control'),d('maintenance','Maintenance'),...b(e)?[d('calibration','Probe calibration'),d('training','Training'),d('exclusion','Exclusion'),d('review','6-month review')]:[],d('rules','House Rules'),d('flow','Flow diagram'),d('matrix','Allergen matrix')];return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cooksafe-records",children:[b(e)&&(0,x.calibrationDue)(c,e.now)?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe calibration due",children:"Open Probe calibration."}):null,(0,m.jsx)(a.Tabs,{value:i,onChange:o,options:u}),'delivery'===i?(0,m.jsx)(R,{who:e}):null,'reheat'===i?(0,m.jsx)(D,{who:e}):null,'offsite'===i?(0,m.jsx)(T,{who:e}):null,'calibration'===i?(0,m.jsx)(k,{who:e}):null,'cleaning'===i?(0,m.jsx)(E,{who:e}):null,'pest'===i?(0,m.jsx)(L,{kind:"pest",who:e,title:"Pest control",intro:"Signs of pests, contractor visits and what was done."}):null,'maintenance'===i?(0,m.jsx)(L,{kind:"maintenance",who:e,title:"Maintenance",intro:"Faults, repairs and equipment checks."}):null,'training'===i?(0,m.jsx)(P,{who:e}):null,'exclusion'===i?(0,m.jsx)(M,{who:e}):null,'review'===i?(0,m.jsx)(B,{who:e}):null,'rules'===i?(0,m.jsx)($,{who:e}):null,'flow'===i?(0,m.jsx)(F,{}):null,'matrix'===i?(0,m.jsx)(O,{rid:s}):null,b(e)?(0,m.jsx)(n.Button,{kind:"secondary",label:"Download CookSafe records (CSV)",testID:"cs-csv",onPress:()=>(0,a.downloadText)(`cooksafe-records-${(new Date).toISOString().slice(0,10)}.csv`,(0,x.csCsv)(c)),style:{alignSelf:'stretch'}}):null]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),n=_r(_d[2]),i=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),m=_r(_d[12]);const p=[],f=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');if(!t||!/^-?\d+(\.\d+)?$/.test(t))return null;const s=Number(t);return s>=-80&&s<=400?s:null},j=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}),y=e=>e.replace(' (example)',''),b=e=>'staff'!==e.mode;function S({children:e}){return(0,m.jsx)(n.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:e})}function w({text:e,testID:t}){return(0,m.jsx)(l.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:t,children:(0,m.jsx)(n.T,{size:14,colour:i.colours.red,center:!0,children:e})})}function I(e){const s=(0,r.useCookSafe)(e=>e.records)??p;return(0,t.useMemo)(()=>s.filter(t=>t.kind===e&&!t.archived),[s,e])}function v({kind:e,who:t,testID:s}){const o=I(e);return(0,m.jsxs)(a.Box,{testID:s,style:{alignItems:'center'},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:["Recent ",x.CS_KIND_LABEL[e].toLowerCase()," records"]}),o.length?o.slice(0,15).map(e=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:2},accessible:!0,accessibilityLabel:`${j(e.at)}, ${e.by}: ${(0,x.recordSummary)(e)}`,children:[(0,m.jsx)(n.T,{size:14,center:!0,colour:!1===e.doc.ok||!1===e.doc.accepted?i.colours.amber:i.colours.text,children:(0,x.recordSummary)(e)}),(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[j(e.at)," \xb7 ",e.by]}),b(t)?(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Archive",testID:`cs-archive-${e.id}`,accessibilityLabel:"Archive this record. It stays in the history.",onPress:()=>r.useCookSafe.getState().archive(e.id)}):null]},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"Nothing recorded yet."})]})}const C=e=>({by:y(e.me),byId:e.meId});function D({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(!1),b=f(o),I=null!==b&&(0,x.reheatOk)(b),D=s.trim()?null===b?'Type the core temperature, for example 84.':!I&&d.trim().length<3?`Below ${x.REHEAT_MIN_C}\xb0C: write what you did (for example \u201cReheated again to 85\xb0C\u201d).`:'':'Type the food you reheated.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-reheat",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Reheating"}),(0,m.jsxs)(n.Muted,{center:!0,children:["In Scotland reheated food must reach ",x.REHEAT_MIN_C,"\xb0C or above in the centre."]}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-reheat-food",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Core temperature (\xb0C)",testID:"cs-reheat-temp",value:o,onChangeText:c,keyboardType:"numbers-and-punctuation",maxLength:6}),null===b||I?null:(0,m.jsx)(n.Field,{label:"What you did (below 82\xb0C)",testID:"cs-reheat-action",value:d,onChangeText:u,maxLength:200}),j&&D?(0,m.jsx)(w,{text:D,testID:"cs-reheat-problem"}):null,(0,m.jsx)(n.Button,{label:"Save reheat check",testID:"cs-reheat-save",onPress:()=>{y(!0),D||(r.useCookSafe.getState().add('reheat',{food:s.trim(),value:b,ok:I,action:d.trim()||void 0},C(e)),p(`Saved: ${s.trim()} ${b}\xb0C.`),i(''),c(''),u(''),y(!1))},style:{alignSelf:'stretch'}}),h?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:h})}):null]}),(0,m.jsx)(v,{kind:"reheat",who:e,testID:"cs-reheat-list"})]})}function k({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[o,c]=(0,t.useState)('Probe 1'),[d,u]=(0,t.useState)(''),[h,j]=(0,t.useState)(''),[y,b]=(0,t.useState)(''),[I,D]=(0,t.useState)(!1),[k,T]=(0,t.useState)(''),R=f(d),L=f(h),P=null!==R&&null!==L&&(0,x.calibrationOk)(R,L),M=null===R?'Type the iced water reading, for example 0.':null===L?'Type the boiling water reading, for example 100.':!P&&y.trim().length<3?'Out of range: write what you did (for example \u201cProbe replaced\u201d).':'',B=(0,x.calibrationDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-calibration",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Probe calibration (monthly)"}),B?(0,m.jsx)(n.Banner,{kind:"warn",title:"Monthly probe check due",children:"Check each probe in iced water and boiling water."}):(0,m.jsx)(n.Muted,{center:!0,children:"Done this month."}),(0,m.jsx)(n.Muted,{center:!0,children:"Iced water should read \u22121 to +1\xb0C. Boiling water should read 99 to 101\xb0C."}),(0,m.jsx)(n.Field,{label:"Probe name",testID:"cs-cal-probe",value:o,onChangeText:c,maxLength:40}),(0,m.jsx)(n.Field,{label:"Iced water reading (\xb0C)",testID:"cs-cal-ice",value:d,onChangeText:u,keyboardType:"numbers-and-punctuation",maxLength:6}),null===R||(0,x.iceOk)(R)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Iced water out of range."}),(0,m.jsx)(n.Field,{label:"Boiling water reading (\xb0C)",testID:"cs-cal-boil",value:h,onChangeText:j,keyboardType:"numbers-and-punctuation",maxLength:6}),null===L||(0,x.boilOk)(L)?null:(0,m.jsx)(n.T,{size:14,colour:i.colours.amber,center:!0,children:"Boiling water out of range."}),null===R||null===L||P?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-cal-action",value:y,onChangeText:b,maxLength:200}),I&&M?(0,m.jsx)(w,{text:M}):null,(0,m.jsx)(n.Button,{label:"Save probe check",testID:"cs-cal-save",onPress:()=>{D(!0),M||(r.useCookSafe.getState().add('calibration',{probe:o.trim()||'Probe',ice:R,boil:L,ok:P,action:y.trim()||void 0},C(e)),T(`Saved: ${o} ${P?'passed':'failed'}.`),u(''),j(''),b(''),D(!1))},style:{alignSelf:'stretch'}}),k?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:k})}):null]}),(0,m.jsx)(v,{kind:"calibration",who:e,testID:"cs-cal-list"})]})}function T({who:e}){const[s,i]=(0,t.useState)(''),[o,c]=(0,t.useState)(''),[d,u]=(0,t.useState)('chilled'),[h,p]=(0,t.useState)(''),[j,y]=(0,t.useState)(''),[b,I]=(0,t.useState)(!1),[D,k]=(0,t.useState)(''),T=f(h),R=null!==T&&(0,x.offsiteOk)(d,T),L=s.trim()?o.trim()?null===T?'Type the temperature.':!R&&j.trim().length<3?'Out of range: write what you did.':'':'Type the food.':'Type where (for example \u201cWedding, Kilmun Hall\u201d).';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-offsite",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Off-site temperatures"}),(0,m.jsx)(n.Muted,{center:!0,children:"Outside catering, events and food carried off site: chilled 8\xb0C or below, frozen \u221215\xb0C or below, hot 63\xb0C or above."}),(0,m.jsx)(n.Field,{label:"Where",testID:"cs-off-place",value:s,onChangeText:i,maxLength:80}),(0,m.jsx)(n.Field,{label:"Food",testID:"cs-off-food",value:o,onChangeText:c,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','hot'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:d===e,testID:`cs-off-${e}`,onPress:()=>u(e)},e))}),(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-off-temp",value:h,onChangeText:p,keyboardType:"numbers-and-punctuation",maxLength:6}),null===T||R?null:(0,m.jsx)(n.Field,{label:"What you did",testID:"cs-off-action",value:j,onChangeText:y,maxLength:200}),b&&L?(0,m.jsx)(w,{text:L}):null,(0,m.jsx)(n.Button,{label:"Save off-site check",testID:"cs-off-save",onPress:()=>{I(!0),L||(r.useCookSafe.getState().add('offsite',{place:s.trim(),food:o.trim(),type:d,value:T,ok:R,action:j.trim()||void 0},C(e)),k('Saved.'),c(''),p(''),y(''),I(!1))},style:{alignSelf:'stretch'}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:D})}):null]}),(0,m.jsx)(v,{kind:"offsite",who:e,testID:"cs-off-list"})]})}function R({who:e}){const s=(0,o.useGpCalc)(e=>e.deliveries),i=(0,t.useMemo)(()=>Object.values(s??{}).filter(t=>t.date>=new Date(e.now.getTime()-2592e5).toISOString().slice(0,10)).sort((e,t)=>t.date.localeCompare(e.date)).slice(0,8),[s,e.now]),[c,d]=(0,t.useState)(null),[u,h]=(0,t.useState)(''),[p,j]=(0,t.useState)(''),[y,b]=(0,t.useState)('chilled'),[I,D]=(0,t.useState)(''),[k,T]=(0,t.useState)(!0),[R,L]=(0,t.useState)(''),[P,M]=(0,t.useState)(!1),[B,$]=(0,t.useState)(''),F=f(I),E=(0,x.deliveryOk)(y,F),O=u.trim()?'ambient'!==y&&null===F?'Type the delivery temperature.':!E&&k?'Too warm: reject it, or write why it was accepted.':'':'Type or pick the supplier.',_=O&&!(O.startsWith('Too warm')&&R.trim().length>=3);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-delivery",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Delivery record"}),(0,m.jsx)(n.Muted,{center:!0,children:"Chilled 8\xb0C or below, frozen \u221215\xb0C or below. Packaging intact, in date."}),i.length?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Muted,{center:!0,children:"From goods-in:"}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.map(e=>(0,m.jsx)(n.Chip,{label:e.supplier,sub:e.date.split('-').reverse().join('/'),selected:c===e.id,testID:`cs-del-goods-${e.id}`,onPress:()=>{d(e.id),h(e.supplier),j(`${e.lines.length} line${1===e.lines.length?'':'s'}`)}},e.id))})]}):(0,m.jsx)(n.Muted,{center:!0,children:"No goods-in from the last three days to link."}),(0,m.jsx)(n.Field,{label:"Supplier",testID:"cs-del-supplier",value:u,onChangeText:h,maxLength:60}),(0,m.jsx)(n.Field,{label:"Items",testID:"cs-del-items",value:p,onChangeText:j,maxLength:120}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['chilled','frozen','ambient'].map(e=>(0,m.jsx)(n.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:y===e,testID:`cs-del-${e}`,onPress:()=>b(e)},e))}),'ambient'!==y?(0,m.jsx)(n.Field,{label:"Temperature (\xb0C)",testID:"cs-del-temp",value:I,onChangeText:D,keyboardType:"numbers-and-punctuation",maxLength:6}):null,(0,m.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:"Accepted",selected:k,testID:"cs-del-accepted",onPress:()=>T(!0)}),(0,m.jsx)(n.Chip,{label:"Rejected",selected:!k,testID:"cs-del-rejected",onPress:()=>T(!1)})]}),(0,m.jsx)(n.Field,{label:"Note",testID:"cs-del-note",value:R,onChangeText:L,maxLength:200}),P&&_?(0,m.jsx)(w,{text:O}):null,(0,m.jsx)(n.Button,{label:"Save delivery",testID:"cs-del-save",onPress:()=>{M(!0),_||(r.useCookSafe.getState().add('delivery',{supplier:u.trim(),items:p.trim(),type:y,value:'ambient'===y?null:F,ok:E,accepted:k,note:R.trim()||void 0,goodsInId:c??void 0},C(e)),$(`Saved: ${u.trim()} ${k?'accepted':'rejected'}.`),d(null),h(''),j(''),D(''),L(''),T(!0),M(!1))},style:{alignSelf:'stretch'}}),B?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:B})}):null]}),(0,m.jsx)(v,{kind:"delivery",who:e,testID:"cs-del-list"})]})}function L({kind:e,who:s,title:i,intro:o}){const[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),[x,p]=(0,t.useState)(''),[f,j]=(0,t.useState)(!1),[y,b]=(0,t.useState)(''),I=c.trim().length<3?'Write what was found or checked.':'';return(0,m.jsxs)(l.default,{style:{gap:12},testID:`cs-${e}`,children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:i}),(0,m.jsx)(n.Muted,{center:!0,children:o}),(0,m.jsx)(n.Field,{label:'pest'===e?'What was seen or checked':'Fault or job',testID:`cs-${e}-what`,value:c,onChangeText:d,maxLength:200,multiline:!0}),(0,m.jsx)(n.Field,{label:"Action taken",testID:`cs-${e}-action`,value:u,onChangeText:h,maxLength:200}),(0,m.jsx)(n.Field,{label:"Contractor (optional)",testID:`cs-${e}-contractor`,value:x,onChangeText:p,maxLength:60}),f&&I?(0,m.jsx)(w,{text:I}):null,(0,m.jsx)(n.Button,{label:"Save",testID:`cs-${e}-save`,onPress:()=>{j(!0),I||(r.useCookSafe.getState().add(e,{what:c.trim(),action:u.trim()||void 0,contractor:x.trim()||void 0},C(s)),b('Saved.'),d(''),h(''),p(''),j(!1))},style:{alignSelf:'stretch'}}),y?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:y})}):null]}),(0,m.jsx)(v,{kind:e,who:s,testID:`cs-${e}-list`})]})}function P({who:e}){const s=(0,d.useOwner)(e=>e.staff),i=(0,t.useMemo)(()=>(s??[]).filter(e=>!e.archived).map(e=>y(e.name)).sort(),[s]),[o,c]=(0,t.useState)(''),[x,p]=(0,t.useState)('Induction'),[f,j]=(0,t.useState)(''),[b,I]=(0,t.useState)(''),[D,k]=(0,t.useState)(''),[T,R]=(0,t.useState)(!1),[L,P]=(0,t.useState)(''),M=(0,h.parseDmy)(b),B=D.trim()?(0,h.parseDmy)(D):'',$=o.trim()?f.trim()?M?null===B?'Type the renewal date like 20/11/2029, or leave it empty.':'':'Type the date done like 20/11/2026.':'Type what the training was (for example \u201cFood hygiene level 2\u201d).':'Pick or type the person.';return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-training",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Training and induction"}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-tr-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:i.slice(0,24).map(e=>(0,m.jsx)(n.Chip,{label:e,selected:o===e,onPress:()=>c(e)},e))}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['Induction','Training','Refresher'].map(e=>(0,m.jsx)(n.Chip,{label:e,selected:x===e,testID:`cs-tr-${e.toLowerCase()}`,onPress:()=>p(e)},e))}),(0,m.jsx)(n.Field,{label:"What (course or topic)",testID:"cs-tr-course",value:f,onChangeText:j,maxLength:100}),(0,m.jsx)(n.Field,{label:"Date done (DD/MM/YYYY)",testID:"cs-tr-done",value:b,onChangeText:e=>I((0,u.slashDate)(e,b)),keyboardType:"numbers-and-punctuation",maxLength:10}),(0,m.jsx)(n.Field,{label:"Renew by (DD/MM/YYYY, optional)",testID:"cs-tr-expires",value:D,onChangeText:e=>k((0,u.slashDate)(e,D)),keyboardType:"numbers-and-punctuation",maxLength:10}),T&&$?(0,m.jsx)(w,{text:$}):null,(0,m.jsx)(n.Button,{label:"Save training record",testID:"cs-tr-save",onPress:()=>{R(!0),$||(r.useCookSafe.getState().add('training',{person:o.trim(),type:x,course:f.trim(),done:M,expires:B||void 0},C(e)),P(`Saved for ${o.trim()}.`),j(''),I(''),k(''),R(!1))},style:{alignSelf:'stretch'}}),L?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:L})}):null]}),(0,m.jsx)(v,{kind:"training",who:e,testID:"cs-tr-list"})]})}function M({who:e}){const s=I('exclusion'),[o,c]=(0,t.useState)(''),[d,p]=(0,t.useState)(''),[f,b]=(0,t.useState)(!1),[v,D]=(0,t.useState)(''),k=(0,h.parseDmy)(d),T=o.trim()?k?'':'Type the first day off like 20/11/2026.':'Type the person.',R=e=>r.useCookSafe.getState().update(e.id,{stopped:(new Date).toISOString()}),L=t=>r.useCookSafe.getState().update(t.id,{returned:(new Date).toISOString().slice(0,10),returnBy:y(e.me)});return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-exclusion",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Exclusion and return to work"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Food handlers with sickness or diarrhoea stay off until ",x.EXCLUSION_HOURS," hours after the symptoms stop."]}),(0,m.jsx)(n.Field,{label:"Person",testID:"cs-ex-person",value:o,onChangeText:c,maxLength:60}),(0,m.jsx)(n.Field,{label:"First day off (DD/MM/YYYY)",testID:"cs-ex-from",value:d,onChangeText:e=>p((0,u.slashDate)(e,d)),keyboardType:"numbers-and-punctuation",maxLength:10}),f&&T?(0,m.jsx)(w,{text:T}):null,(0,m.jsx)(n.Button,{label:"Record off work",testID:"cs-ex-save",onPress:()=>{b(!0),T||(r.useCookSafe.getState().add('exclusion',{person:o.trim(),from:k},C(e)),D(`Saved: ${o.trim()} off work.`),c(''),p(''),b(!1))},style:{alignSelf:'stretch'}}),v?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:v})}):null]}),(0,m.jsxs)(a.Box,{testID:"cs-ex-list",style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Off work and returns"}),s.length?s.slice(0,12).map(t=>{const s=t.doc,a=(0,x.mayReturn)(s.stopped,e.now);return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{center:!0,children:(0,x.recordSummary)(t)}),s.returned?(0,m.jsx)(n.Muted,{center:!0,children:"Back at work."}):s.stopped?a?(0,m.jsx)(n.Button,{small:!0,label:"Return to work",testID:`cs-ex-return-${t.id}`,accessibilityLabel:`${s.person} may return: ${x.EXCLUSION_HOURS} hours have passed. Record the return to work.`,onPress:()=>L(t)}):(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,children:["Not before ",j((0,x.returnFrom)(s.stopped).toISOString())]}):(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Symptoms stopped now",testID:`cs-ex-stopped-${t.id}`,onPress:()=>R(t)})]},t.id)}):(0,m.jsx)(n.Muted,{center:!0,children:"Nobody is recorded off work."})]})]})}function B({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(x.REVIEW_QUESTIONS.map(()=>!1)),[c,d]=(0,t.useState)(''),[u,h]=(0,t.useState)(''),f=(0,x.reviewDue)(s,e.now);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-review",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"Six-monthly CookSafe review"}),f?(0,m.jsx)(n.Banner,{kind:"warn",title:"Review due",children:"Go through your CookSafe manual at least every six months, and whenever the menu, suppliers or equipment change."}):(0,m.jsx)(n.Muted,{center:!0,children:"Reviewed in the last six months."}),x.REVIEW_QUESTIONS.map((e,t)=>(0,m.jsx)(n.Toggle,{label:e,value:i[t],testID:`cs-rev-${t}`,onChange:e=>o(s=>s.map((s,l)=>l===t?e:s))},e)),(0,m.jsx)(n.Field,{label:"Changes made (optional)",testID:"cs-rev-note",value:c,onChangeText:d,maxLength:500,multiline:!0}),(0,m.jsx)(n.Button,{label:"Sign the review",testID:"cs-rev-save",onPress:()=>{r.useCookSafe.getState().add('review',{answers:i,note:c.trim()||void 0},C(e)),h('Review saved and dated.'),o(x.REVIEW_QUESTIONS.map(()=>!1)),d('')},disabled:!b(e),style:{alignSelf:'stretch'}}),u?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:u})}):null]}),(0,m.jsx)(v,{kind:"review",who:e,testID:"cs-rev-list"})]})}function $({who:e}){const s=(0,r.useCookSafe)(e=>e.records)??p,[i,o]=(0,t.useState)(null),[c,d]=(0,t.useState)(''),u=b(e),h=e=>s.find(t=>t.id===(0,r.ruleRecordId)(e)),f=(t,s,l)=>{const n=h(t),i=(new Date).toISOString(),a=y(e.me),o=n?.doc??{},c=void 0!==l.text?'Wording changed':l.inPlace?'Ticked as in place':'Unticked',d={title:s,inPlace:l.inPlace??o.inPlace??!1,text:l.text??o.text,history:[...o.history??[],{at:i,by:a,what:c}].slice(-30)};n?r.useCookSafe.getState().update(n.id,d):r.useCookSafe.getState().add('houserule',d,C(e),i,(0,r.ruleRecordId)(t))};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-rules",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"House Rules"}),(0,m.jsxs)(n.Muted,{center:!0,children:["Standard CookSafe House Rules wording. ",u?'Tick each one that is in place, or change the wording to fit your kitchen. Every change is dated.':'Read by everyone in the kitchen.']})]}),x.HOUSE_RULES.map(e=>{const t=h(e.id),s=t?.doc??{},l=s.history?.[s.history.length-1];return(0,m.jsxs)(a.Box,{testID:`cs-rule-${e.id}`,style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:e.title}),i===e.id?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(n.Field,{label:`${e.title} wording`,testID:`cs-rule-text-${e.id}`,value:c,onChangeText:d,multiline:!0,maxLength:1e3}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Button,{small:!0,label:"Save wording",testID:`cs-rule-save-${e.id}`,onPress:()=>{f(e.id,e.title,{text:c.trim()||e.text}),o(null)}}),(0,m.jsx)(n.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>o(null)})]})]}):(0,m.jsx)(n.T,{size:14,center:!0,children:s.text??e.text}),u?(0,m.jsxs)(n.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(n.Chip,{label:s.inPlace?'In place \u2713':'Tick: in place',selected:!!s.inPlace,testID:`cs-rule-tick-${e.id}`,onPress:()=>f(e.id,e.title,{inPlace:!s.inPlace})}),i!==e.id?(0,m.jsx)(n.Chip,{label:"Edit wording",testID:`cs-rule-edit-${e.id}`,onPress:()=>{o(e.id),d(s.text??e.text)}}):null]}):s.inPlace?(0,m.jsx)(n.Muted,{center:!0,children:"In place"}):null,l?(0,m.jsxs)(n.Muted,{size:12,center:!0,children:[l.what,": ",j(l.at)," \xb7 ",l.by]}):null]},e.id)})]})}function F(){return(0,m.jsxs)(l.default,{style:{gap:6,alignItems:'center'},testID:"cs-flow",accessibilityRole:"list",children:[(0,m.jsx)(S,{children:"Food flow"}),(0,m.jsx)(n.Muted,{center:!0,children:"How food moves through the kitchen, with the limit checked at each step."}),x.FLOW_STEPS.map((e,t)=>(0,m.jsxs)(s.default.Fragment,{children:[(0,m.jsxs)(l.default,{accessibilityRole:"text",accessibilityLabel:`Step ${t+1}, ${e.title}: ${e.limit}`,testID:`cs-flow-${e.id}`,style:{alignSelf:'stretch',alignItems:'center',padding:12,borderRadius:14,borderWidth:1.5,borderColor:i.colours.gold,backgroundColor:i.colours.surface},children:[(0,m.jsxs)(n.T,{weight:"semibold",center:!0,colour:i.colours.gold,children:[t+1,". ",e.title]}),(0,m.jsx)(n.T,{size:14,center:!0,children:e.limit})]}),te.records)??p,o=(0,t.useMemo)(()=>(0,r.scheduleOf)(s),[s]),c=(0,t.useMemo)(()=>new Set((0,x.cleaningDue)(o,s,e.now).map(e=>e.id)),[o,s,e.now]),[d,u]=(0,t.useState)(''),[h,f]=(0,t.useState)('daily'),[j,y]=(0,t.useState)(''),S=t=>{const s=r.useCookSafe.getState();s.records.find(e=>e.id===r.SCHEDULE_ID)?s.update(r.SCHEDULE_ID,{schedule:t}):s.add('cleaning',{schedule:t,task:'Cleaning schedule'},C(e),void 0,r.SCHEDULE_ID)};return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-cleaning",children:[['daily','weekly','monthly'].map(t=>(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:x.FREQ_LABEL[t]}),o.filter(e=>e.freq===t).map(t=>(0,m.jsxs)(l.default,{style:{alignItems:'center',gap:4,alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,colour:c.has(t.id)?i.colours.amber:i.colours.text,children:[t.task,c.has(t.id)?' \xb7 due':' \xb7 done']}),(0,m.jsx)(n.Button,{small:!0,label:"Done",testID:`cs-clean-${t.id}`,accessibilityLabel:`${t.task} done`,onPress:()=>{return s=t.id,l=t.task,r.useCookSafe.getState().add('cleaning',{taskId:s,task:l},C(e)),void y(`${l}: done.`);var s,l}})]},t.id))]},t)),j?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(n.Muted,{center:!0,children:j})}):null,b(e)?(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Add to the schedule"}),(0,m.jsx)(n.Field,{label:"Cleaning task",testID:"cs-clean-new",value:d,onChangeText:u,maxLength:80}),(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:['daily','weekly','monthly'].map(e=>(0,m.jsx)(n.Chip,{label:x.FREQ_LABEL[e],selected:h===e,onPress:()=>f(e)},e))}),(0,m.jsx)(n.Button,{label:"Add task",testID:"cs-clean-add",disabled:d.trim().length<3,onPress:()=>{S([...o,{id:`cl-${Date.now().toString(36)}`,task:d.trim(),freq:h}]),u('')},style:{alignSelf:'stretch'}})]}):null,(0,m.jsx)(v,{kind:"cleaning",who:e,testID:"cs-clean-list"})]})}function O({rid:e}){const s=(0,c.useRecipeCards)(e),r=(0,t.useMemo)(()=>(0,x.allergenMatrix)(s),[s]);return(0,m.jsxs)(l.default,{style:{gap:12},testID:"cs-matrix",children:[(0,m.jsxs)(a.Box,{style:{alignItems:'center'},children:[(0,m.jsx)(S,{children:"14-allergen matrix"}),(0,m.jsx)(n.Muted,{center:!0,children:"Built only from recipe cards the Head Chef has signed off, from each card\u2019s own allergens. \u201cMay\u201d means may contain."}),r.left?(0,m.jsxs)(n.T,{size:14,colour:i.colours.amber,center:!0,testID:"cs-matrix-left",children:[r.left," card",1===r.left?'':'s'," waiting for sign-off ",1===r.left?'is':'are'," left out."]}):null,(0,m.jsx)(n.Button,{label:"Print allergen matrix",testID:"cs-matrix-print",disabled:!r.rows.length,onPress:()=>(0,a.printTable)('Allergen matrix (14 allergens)',`From signed-off recipe cards only \xb7 printed ${(new Date).toLocaleDateString('en-GB')}`,x.MATRIX_HEAD,r.rows.map(e=>[e.dish,...e.cells.map(x.matrixCell)])),style:{alignSelf:'stretch'}})]}),(0,m.jsx)(a.Box,{style:{alignItems:'center'},children:r.rows.length?r.rows.map(e=>(0,m.jsx)(n.T,{size:14,center:!0,testID:`cs-matrix-row-${e.id}`,children:(0,x.matrixSpoken)(e)},e.id)):(0,m.jsx)(n.Muted,{center:!0,children:"No signed-off cards yet."})})]})}},1218,[17,85,777,804,889,992,905,858,876,1033,1217,990,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1219,[]); +__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,"ds",{enumerable:!0,get:function(){return k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-ok\"]{animation:ccal-glow-ok 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;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.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by email",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1220,[843,1028,17,219,385,85,780,858,804,777,1221,1104,1222,8]); +__d(function(_g,r,i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1221,[843,17,363,219,385,85,19,804,777,779,1104,858,8,260]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};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 a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);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]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1222,[1223,1224,1226,1225,1227,1018,1228]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1223,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1224,[824,805,831,834,856,1018,1225]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1225,[843,219,856,1223]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1226,[17,858,845,853,851,1224,1223]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1227,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1228,[17,1224,899,928]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1229,[17,385,85,409,858,845,804,777,1220,1104,1230,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,"unconfirmedTakeaways",{enumerable:!0,get:function(){return x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1230,[17,85,409,858,845,1222,1018,804,777,1104,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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1231,[17,219,385,85,864,777,804,916,1232,1233,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1232,[856,806,928,971,916,1222,1233]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1233,[824,1234,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1234,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1235,[17,856,1232]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1236,[17,385,329,85,409,804,1184,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(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1237,[13,17,775,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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),l=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},h=_r(d[8]),c=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),k=_r(d[14]),j=_r(d[15]),x=_r(d[16]),v=_r(d[17]),C=_r(d[18]),w=_r(d[19]),S=_r(d[20]),D=_r(d[21]),$=_r(d[22]),P=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),B=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,v.useRestaurant)(e),I=(0,v.useCustomer)(),R=(0,v.useBookings)(e),q=(0,v.useEvents)(e),z=(0,v.useNow)(6e4),[N]=(0,i.useState)(()=>(0,a.startForm)()),[F,W]=(0,i.useState)(''),[L,H]=(0,i.useState)(2),[E,_]=(0,i.useState)(0),Y=Math.min(E,Math.max(0,L-1)),[U,G]=(0,i.useState)(r??(0,x.ymd)(z)),[Q,V]=(0,i.useState)(null),[J,K]=(0,i.useState)(I.name),[X,Z]=(0,i.useState)(I.phone??''),[ee,te]=(0,i.useState)(I.email??''),[oe,ne]=(0,i.useState)(!1),[se,ie]=(0,i.useState)(''),[le,ae]=(0,i.useState)(!1),[re,de]=(0,i.useState)(!1),[ue,he]=(0,i.useState)([]),[ce,ge]=(0,i.useState)(!1),me=[...I.allergies,...ue.filter(e=>!I.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[pe,be]=(0,i.useState)(null),fe=(0,$.useBlocks)(e=>e.blocks);(0,C.usePublicDayStore)(e=>e.n);const ye=e?(0,C.publicDay)(e,U):null,ke=ye?[...ye.bookings,...R.filter(e=>e.date!==U)]:R,je=ye?[...fe.filter(t=>t.rid!==e||t.date!==U),...ye.blocks]:fe,xe=(0,P.usePlan)(e),[ve,Ce]=(0,i.useState)((0,M.emptyNeeds)()),we=!0===ve.dog,Se=we?ve.dogs:0;if(!A)return(0,B.jsx)(f.Screen,{title:"Not found",children:(0,B.jsx)(f.T,{children:"Restaurant not found."})});const De=A.settings,$e=(0,x.parseYmd)(U),Pe=(0,j.onlinePartyBounds)(A),Te=(0,$.blocksOn)(je,A.id,U),Me=ke.filter(e=>e.date===U),Oe=xe.areas.filter(e=>e.dogs),Be=(0,b.dogSetUp)(xe),Ae=e=>(0,T.freeTablesAt)(xe,Me,L,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,T.turnFor)(L,De.turnMins),De.turnMins,{dog:!0,closed:(0,$.closedAreasAt)(je,A.id,U,e)}),Ie=(0,j.bookingSlots)(A,$e,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),L,z,e=>ke.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,$.blockAt)(je,A.id,U,e.time),o=we&&Be&&e.available&&!t&&(!Ae(e.time).length||!(0,M.dogTimeOk)(A,ke,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Re=Ie.some(e=>e.available),qe=(0,h.depositOf)(De),ze=(0,p.bookingRulesOf)(A),Ne=(0,p.bookingDepositSplit)(qe,L,Y,(0,M.needsPatch)(ve,I.allergies),(0,b.reservablesOf)(A)),Fe=Ne.total,We=(0,h.depositDue)(qe,L,Y),Le=(0,p.dogPartyCheck)(ze,L,we,ve.assistDog,A.phone),He=(0,p.largeGroupTables)(ze,L),Ee=(0,p.emailRequired)(ze,'online'),Ye=Fe>0?'deposit':'none',Ue=(0,h.depositWords)(qe,L,A.name,Y),Ge=q.filter(e=>e.date===U),Qe=(0,D.guestPhone)(X),Ve=(0,D.emailOk)(ee)&&(!Ee||!!ee.trim()),Je=(0,M.needsMissing)(ve,I.allergies),Ke=!!Q&&(le||!ze.allergyConfirm)&&!Je.length&&J.trim().length>1&&Qe.ok&&Ve&&Le.ok,Xe=Je[0]??(Le.ok?Ee&&!ee.trim()?'Add your email':ze.allergyConfirm&&!le?'Confirm the allergy information':void 0:'Bringing a dog? Please phone us'),Ze=async()=>{const e=(0,M.needsPatch)(ve,I.allergies),t=we&&Be?Ae(Q).map(e=>e.table):[],o=we?ve.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await v.repo.bookings.create({restaurantId:A.id,customerId:I.id,name:J,partySize:L,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ye,depositPaid:0,...Fe?{...(0,p.depositFields)(Ne),depositPolicy:Ue.join(' '),depositRefundable:qe.refundable,depositCutoffHours:qe.cutoffHours}:{},phone:Qe.pretty,email:ee.trim()||void 0,...(0,p.marketingChoice)(ee,ze.marketingOptIn&&re),...le?{allergyConfirmed:!0,allergyConfirmedAt:(new Date).toISOString()}:{},source:'online',...e,...!He||e.tableReq?.length||we?{}:{tableReq:[He.join('+')]},...Ie.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??me,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...N,hp:F})),be(n)},et=(0,v.useStore)(e=>pe?e.bookings.find(e=>e.id===pe.id)?.ref:void 0),tt=e=>(0,S.waMeLink)(A.settings.whatsapp,(0,S.guestWhatsAppText)({name:e.name,ref:et??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(pe){const e='pending'===pe.status;return(0,B.jsxs)(f.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,B.jsx)(f.Banner,{kind:e?'info':'success',title:`Reference ${et??pe.ref}`,children:`${pe.partySize} people \xb7 ${(0,x.niceDateYear)((0,x.parseYmd)(pe.date))} at ${pe.time}`}),e?(0,B.jsx)(f.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(f.T,{children:["Name: ",pe.name]}),(0,B.jsxs)(f.T,{children:["Mobile: ",pe.phone]}),pe.email?(0,B.jsxs)(f.T,{children:["Email: ",pe.email]}):null,(0,B.jsxs)(f.T,{children:["Allergies shared with the restaurant: ",pe.allergies.length?pe.allergies.map(e=>`${(0,y.allergenLabel)(e.allergen)} (${(0,y.severityLabel)(e.severity)})`).join(', '):'none']}),pe.notes?(0,B.jsxs)(f.T,{children:["Notes: ",pe.notes]}):null,pe.dog?(0,B.jsxs)(f.T,{children:["\ud83d\udc15 Dog coming too",pe.table?` \xb7 dog-friendly table ${pe.table}`:'']}):null,pe.holds?.length?(0,B.jsxs)(f.T,{children:["Reserved: ",pe.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??b.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,pe.tableReq?.length?(0,B.jsxs)(f.T,{children:["Table requested: ",pe.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===pe.security&&pe.depositDue?(0,B.jsxs)(f.T,{weight:"semibold",children:["Deposit due: ",(0,k.gbp)(pe.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===pe.security&&pe.depositPolicy?(0,B.jsx)(f.Muted,{children:pe.depositPolicy}):null,(0,B.jsx)(f.Muted,{children:"Your booking details are shown above. CoverCharge emails your confirmation with a link to change or cancel."}),(0,B.jsx)(f.Muted,{children:A.phone?`Or call us on ${A.phone} and quote your booking details.`:'Or call the restaurant and quote your booking details.'})]}),tt(pe)?(0,B.jsxs)(u.default,{style:{gap:4},children:[(0,B.jsx)(f.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=tt(pe);e&&(0,S.openWhatsApp)(e)}}),(0,B.jsx)(f.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,B.jsx)(f.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,B.jsxs)(f.Screen,{title:"Book a table",subtitle:A.name,footer:(0,B.jsx)(f.Button,{label:Xe||(L>(De.autoAcceptUpTo??7)?'Send booking request':'Confirm booking'),disabled:!Ke,onPress:()=>Ze(),testID:"confirm-booking"}),children:[(0,B.jsx)(M.FirstQuestions,{rid:A.id,value:ve,onChange:e=>{e.dog===ve.dog&&e.dogs===ve.dogs||V(null),Ce(e)},party:L,audience:"guest",profile:I.allergies}),(0,B.jsxs)(f.Card,{children:[(0,B.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,B.jsx)(f.H2,{children:"Party size"}),(0,B.jsx)(o.PartySizeInput,{value:L,onChange:e=>{H(e),V(null)},min:Pe.min,max:Pe.max,label:"Party size",testID:"party-size"})]}),(0,B.jsx)(c.ChildrenCount,{guest:!0,party:L,value:Y,onChange:_,depositsOn:qe.on&&qe.perPersonPence>0,testID:"book-children"}),Fe?(0,B.jsx)(f.Banner,{kind:"info",title:Ne.preorders&&!We?`Deposit: ${(0,k.gbp)(Fe)} for pre-ordered dishes`:Ne.preorders?`Deposit: ${(0,k.gbp)(Fe)} (${(0,k.gbp)(We)} for the adults, ${(0,k.gbp)(Ne.preorders)} for pre-ordered dishes)`:Y?`Deposit: ${(0,k.gbp)(Fe)} for ${L-Y} adults (children don't count towards the ${qe.fromParty} and don't pay)`:`Deposit: ${(0,k.gbp)(Fe)} for ${L} adults`,children:(0,B.jsx)(u.default,{style:{gap:4},children:Ue.map(e=>(0,B.jsx)(f.T,{size:13,children:e},e))})}):qe.on&&qe.perPersonPence>0?(0,B.jsxs)(f.Muted,{children:["No deposit for fewer than ",qe.fromParty," adults. Children don't count towards the ",qe.fromParty," and don't pay, and staff can waive a deposit."]}):null,Le.ok?null:(0,B.jsx)(f.Banner,{kind:"warn",title:"Bringing a dog?",children:Le.why}),He&&!we?(0,B.jsxs)(f.Muted,{children:["For ",L," people we join tables ",He.join(' + ')," for you."]}):null,L>(De.autoAcceptUpTo??7)?(0,B.jsxs)(f.Muted,{children:["For ",L," people the team checks the booking first, then CoverCharge confirms by email."]}):null,we&&Be?(0,B.jsxs)(f.Muted,{children:["Dogs are welcome in the ",Oe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Date"}),(0,B.jsx)(O.CustomerDatePicker,{r:A,today:z,value:U,events:q,onChange:e=>{G(e),V(null)}}),Ge.map(e=>(0,B.jsx)(f.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Time"}),0===Ie.length?(0,B.jsx)(f.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:Ie.map(e=>(0,B.jsx)(f.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),Te.length>0&&Ie.some(e=>e.blocked)?(0,B.jsx)(f.Banner,{kind:"info",title:Re?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${Te.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,x.niceDate)($e)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Ie.some(e=>e.drinksOnly)?(0,B.jsx)(f.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),we&&Ie.some(e=>e.noDog)?(0,B.jsx)(f.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Oe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,$.closedAreasAt)(je,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,B.jsx)(f.Muted,{children:(0,j.bookingLimitsHint)(A)})]}),(0,B.jsx)(M.MoreQuestions,{rid:A.id,r:A,value:ve,onChange:Ce,party:L,date:U,time:Q,today:(0,x.ymd)(z),bookings:ke,audience:"guest",showTables:!0}),(0,B.jsxs)(f.Card,{highlight:le?void 0:w.colours.amber,children:[(0,B.jsx)(f.Field,{label:"Notes (optional)",value:se,onChangeText:ie,placeholder:ze.notesPlaceholder,multiline:!0,numberOfLines:3,testID:"book-notes"}),ze.allergyConfirm?(0,B.jsx)(f.Toggle,{label:ze.allergyConfirmWords,value:le,onChange:ae,testID:"book-allergy-confirm"}):null,(0,B.jsxs)(f.Muted,{children:[ze.tableRequestNote," ",Ne.preorders?'Pre-ordered dishes with a deposit are shown above; the rest is paid on the night.':'Nothing here is charged now; reserved dishes are paid on the night.']})]}),(0,B.jsxs)(f.Card,{children:[(0,B.jsx)(f.H2,{children:"Your details"}),(0,B.jsx)(f.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,B.jsx)(f.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Qe.ok||!oe&&!X?null:(0,B.jsx)(f.T,{size:13,colour:w.colours.amber,children:Qe.error}),(0,B.jsx)(f.Field,{testID:"book-email",label:Ee?'Email (needed to book)':'Email (optional)',value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),(0,D.emailOk)(ee)?null:(0,B.jsxs)(f.T,{size:13,colour:w.colours.amber,children:["That email doesn\u2019t look quite right.",Ee?'':' Check it, or leave it blank.']}),ze.marketingOptIn&&ee.trim()?(0,B.jsx)(f.Toggle,{label:ze.marketingWords,value:re,onChange:de,testID:"book-marketing"}):null,(0,B.jsx)(f.Muted,{children:"CoverCharge confirms by email, with how to change or cancel. We only use your number for this booking."})]}),(0,B.jsx)(l.Honeypot,{value:F,onChange:W})]})}},1238,[843,1099,861,13,17,1239,917,85,841,1240,1079,1055,777,845,851,1105,863,858,899,804,1181,848,995,998,1076,1107,1241,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1239,[812,17,219,85,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return o}}),_e.ChildrenCount=function({party:e,value:t,onChange:u,depositsOn:h,testID:c="children-count",guest:p}){const f=o(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>u(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children don't count towards the number that needs a deposit, and never pay."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const o=e=>Math.max(0,Math.round(Number(e)||0)-1)},1240,[17,85,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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1241,[17,385,85,862,863,1033,1242,804,777,779,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1242,[1033]); +__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 b}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),l=e(_r(_d[3])),s=e(_r(_d[4])),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,n.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),y=(0,h.useMenu)(e).find(e=>e.id===b),x=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===y?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,t.useTakeawayMenu)(t=>t.byVenue[e]),S=(0,h.useStore)(t=>t.basket.restaurantId===e&&'table'===t.basket.mode),[C,B]=(0,a.useState)(()=>(y?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,a.useState)(1),[P,T]=(0,a.useState)(''),[L,O]=(0,a.useState)(!1),[D,A]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[q,N]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>y?(0,c.effectiveAllergens)(y,C):{},[y,C]);if(!j||!y)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(_,x.allergies),Y=(y.price??0)+(y.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),z=S||j.fictional?'on':(0,t.takeawayAvail)(y,w),F=y.soldOut||!y.signOff||null===y.price||'on'!==z,Q=(e,t)=>{const n=y.optionGroups.find(t=>t.id===e);B(e=>{const a=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!a.includes(e)),t]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:y.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),N(!0)};return(0,f.jsxs)(d.Screen,{title:y.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(l.default,{testID:"dish-photo",source:k,accessibilityLabel:`${y.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===y.price?y.priceNote:(0,u.gbp)(Y)}),y.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:y.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(y.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,f.jsx)(d.Chip,{label:t.label,sub:t.priceDelta?`+${(0,u.gbp)(t.priceDelta)}`:void 0,selected:C.includes(t.id),onPress:()=>Q(e.id,t.id)},t.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:y,map:_,declared:x.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:y.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&y.signOff&&null!==y.price?'Not available for takeaway today. You can have it when you eat in.':y.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>n.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>n.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${y.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1243,[900,13,17,319,85,1244,1246,777,845,851,858,867,804,8]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:s}){return(0,c.jsxs)(a.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,c.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(d.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,n.isLiveVenue)()?null:(0,c.jsx)(d.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,c.jsx)(a.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:t.ALLERGENS.map(e=>{const n=l[e.id],u=s.find(l=>l.allergen===e.id),f='contains'===n?o.colours.redBg:'may'===n?o.colours.amberBg:o.colours.surface2,h='contains'===n?'#FFD9D4':'may'===n?'#FFE2A8':o.colours.muted;return(0,c.jsxs)(a.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?o.colours.red:o.colours.border},children:[(0,c.jsx)(d.T,{size:14,weight:"medium",colour:n?h:o.colours.text,children:e.label}),(0,c.jsxs)(d.T,{size:13,colour:h,children:['contains'===n?'Contains':'may'===n?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,t.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,c.jsxs)(d.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,c.jsx)(a.default,{testID:"allergen-signoff",children:(0,c.jsx)(d.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${u(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,c.jsx)(d.Muted,{children:"Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:l,declared:n,signedOff:s}){const a=Object.entries(l);return a.length?(0,c.jsx)(d.Row,{wrap:!0,gap:5,children:a.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,l])=>{const s=n.some(l=>l.allergen===e);return(0,c.jsx)(d.Badge,{label:`${s?'\u26a0 ':''}${(0,t.allergenLabel)(e)}${'may'===l?' (may)':''}`,kind:s?'contains'===l?'red':'amber':'neutral'},e)})}):(0,c.jsx)(d.Muted,{children:(0,e.noAllergenWords)(s)})};var e=r(_d[0]);r(_d[1]);var l,n=r(_d[2]),s=r(_d[3]),a=(l=s)&&l.__esModule?l:{default:l},t=r(_d[4]),o=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},1244,[901,17,1245,85,845,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1245,[880,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},1246,[13,17,385,858,804,777,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]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1247,[13,17,777,1248,858,1231,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},1248,[17,385,804,777,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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{money:!0,label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1249,[822,13,17,1250,777,851,858,804,1251,1255,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.MockPay=function({visible:e,onClose:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1250,[17,368,85,858,851,804,777,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=y(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{money:!0,label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&f(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:y,err:f,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:f?(0,h.jsx)(a.Banner,{kind:"warn",title:f}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),y.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),y.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=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)}},x=e=>`cc-gift-codes:${e}:v1`;function y(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function f(e,t,n){try{const s=y(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,y]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),y('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){y((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1251,[17,85,777,851,1252,1253,1254,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1252,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return i}}),e.prettyGiftCode=function(n){const t=i(n);return 16===t.length?t.match(/.{4}/g).join('-'):t},e.poundsToPence=s,e.redeemKey=function(n=Math.random){const t='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=t[Math.floor(32*n())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(n){const t=n.split(/[,\s]+/).filter(Boolean).map(s);return!t.length||t.length>6||t.some(n=>null===n||n<100)?null:[...new Set(t)].sort((n,t)=>n-t)},e.basketTotal=function(n,t){return n.reduce((n,r)=>n+(t.find(n=>n.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return u}});var n=_r(d[0]);const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},r='Gift cards are sold through your website. You can also pay at the bar or till.',o={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},i=n=>(n??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function s(t){const r=(0,n.parseMoneyInput)(t);return null==r||r<=0||r>9999.99?null:Math.round(100*r)}const c=n=>n%12==0?`${n/12} year${12===n?'':'s'}`:`${n} months`;const a=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},u=n=>({gifts_on:n.giftsOn,shop_on:n.shopOn,expiry_months:n.expiryMonths,amounts:n.amounts,min_pence:n.minPence,max_pence:n.maxPence,terms:n.terms})},1253,[840]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1254,[928,899,1253]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1255,[831,928,971,899,880,1252]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),O=_r(_d[23]),A=_r(_d[24]),I=_r(_d[25]),R=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),_=_r(_d[29]),C=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const E=['book','takeaway'].includes(_.START_GO??'')?_.START_GO:null;let L=!1,M=!1,$=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,j.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,j.useRestaurant)(e),l=(0,j.useMenu)(e),a=(0,j.useCustomer)(),s=(0,j.useBasket)(),n=(0,j.useStore)(e=>e.startBasket),o=(0,j.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[Y,U]=(0,u.useState)(!1),[V,Q]=(0,u.useState)('takeaway'===E?'takeaway':'main');c.default.useEffect(()=>{E&&!L&&(L=!0,'book'===E?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,I.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,j.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,C.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{_.START_TABLE_TOKEN&&!$&&($=!0,setTimeout(()=>d.router.push(`/table/live/${_.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{_.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,j.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||j.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=e=>!ae&&!t.fictional&&(0,w.takeawayNotToday)(e,le),re=l.filter(e=>('All'===r||e.section===r)&&('takeaway'!==V||'off'!==ne(e)||oe(e))),ie=(0,k.hoursFor)(t,o),de=e=>()=>d.router.push(`/customer/${t.id}${e}`),ue=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Q('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>U(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:de('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:de('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:de('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:de('/refer')},{icon:'gift',label:'Gift cards',on:de('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:de('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:de('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:de('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:de('/feedback')},{icon:'hanger',label:'Lost property',on:de('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:de('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==A.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[ie?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!ie?'amber':'ok',label:t.settings.takeawayPaused?'Paused':ie?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:ue.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ue.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Q(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,v.jsx)(R.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===V?(0,v.jsx)(m.Muted,{children:"Order to collect. Dishes the kitchen can\u2019t do for takeaway today are greyed out; pick a collection slot at checkout."}):null,'specials'!==V?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==V||re.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==V?se.filter(e=>('All'===r||e===r)&&re.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),re.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,'takeaway'===V&&oe(e)?(0,v.jsx)(m.Badge,{kind:"neutral",label:w.NOT_TODAY_LABEL}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies,signedOff:!!e.signOff}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?w.NOT_TODAY_LABEL:'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(O.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:Y,onClose:()=>U(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{U(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1256,[1257,1258,805,1259,1268,1269,1270,843,13,17,219,385,85,1244,1246,777,845,851,862,858,900,804,1271,1231,856,876,1272,910,911,920,1274,1255,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1257,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1258,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1259,[17,85,777,1260,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:D,onClose:f}){const[v,C]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),I=e=>C(t=>({...t,...e})),[S,B]=(0,l.useState)(''),[w,P]=(0,l.useState)(''),[Y,M]=(0,l.useState)(null),[N,$]=(0,l.useState)(''),[L,V]=(0,l.useState)(!1),[z,R]=(0,l.useState)(!1),F=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&M(e)}).catch(n=>{s&&$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const H=async()=>{if(F.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,v,D):q&&'table'===u?(0,o.allDayRequestError)(v,q):(0,r.errorForVenue)(e,u,v,h);if(s)$(s);else if(Y&&S.trim()){F.current=!0,R(!0),$('');try{await(0,x.sendVenueRequest)(e,u,v,Y.id,S,w),V(!0)}catch(s){$((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{F.current=!1,R(!1)}}else $('Complete the security check.')},Q={minHeight:48,fontSize:18,color:p.colours.text};return(0,j.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,j.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,j.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),L?(0,j.jsx)(y.Banner,{kind:"info",title:(0,k.requestSentTitle)(e,h?.enabled),children:"Nothing has been charged. No email or text is sent by this app."}):(0,j.jsxs)(j.Fragment,{children:['table'===u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(v.date,e=>I({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,j.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,j.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(v.service===e?' \xb7 selected':''),kind:v.service===e?'primary':'secondary',onPress:()=>I({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,j.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,v.date||'',D):q?(0,o.allDaySlots)(v.date||'',q):(0,r.slotsForVenue)(e,v.date||'',v.service||'Lunch')).map(e=>(0,j.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(v.time===e?' \xb7 selected':''),kind:v.time===e?'primary':'secondary',onPress:()=>I({time:e}),style:{alignSelf:'auto'}},e))}),(0,j.jsx)(T,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(v.covers??''),onChangeText:e=>I({covers:Number(e)}),style:Q})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,j.jsx)(T,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(v.checkIn,e=>I({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(T,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(v.checkOut,e=>I({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:Q}),(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,j.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${v.roomType===e.id?' \xb7 selected':''}`,kind:v.roomType===e.id?'primary':'secondary',onPress:()=>I({roomType:e.id})},e.id)),(0,j.jsx)(T,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(v.guests??''),onChangeText:e=>I({guests:Number(e)}),style:Q}),(0,j.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(v.addDinner?'Yes':'No'),kind:v.addDinner?'primary':'secondary',onPress:()=>I({addDinner:!v.addDinner})}),(0,j.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,j.jsx)(T,{label:"Name",testID:"request-name",autoComplete:"name",value:v.name,onChangeText:e=>I({name:e}),style:Q}),(0,j.jsx)(T,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:v.phone,onChangeText:e=>I({phone:e}),style:Q}),(0,j.jsx)(T,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:v.email,onChangeText:e=>I({email:e}),style:Q}),(0,j.jsx)(T,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:v.notes,onChangeText:e=>I({notes:e}),style:Q}),(0,j.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,j.jsx)(T,{label:"Leave this empty",value:w,onChangeText:P})}),Y?(0,j.jsx)(T,{label:`Security check: ${Y.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:S,onChangeText:B,style:Q}):(0,j.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),N?(0,j.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:N}):null,(0,j.jsx)(y.Button,{testID:"request-submit",label:z?'Sending request\u2026':'Send request',disabled:z||!Y,onPress:()=>{H()}})]}),(0,j.jsx)(y.Button,{kind:"secondary",label:L?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:f})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]),j=_r(d[13]);function T({label:e,...t}){return(0,j.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,j.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,j.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1260,[806,1033,1261,1263,1265,17,85,812,777,804,1262,1266,1267,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t2e3)return'Keep notes under 2000 characters.';const s=t=>!!t&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(+new Date(t+'T12:00:00Z'))&&new Date(t+'T12:00:00Z').toISOString().slice(0,10)===t;if('table'===t){if(!s(o.date)||o.date200)return'Enter 1 to 200 Covers.'}else{if(!i?.enabled||!s(o.checkIn)||!s(o.checkOut)||o.checkIn60)return'Choose check-in and a later check-out, up to 60 nights.';if(!i.roomTypes.some(t=>t.id===o.roomType)||!Number.isInteger(o.guests)||o.guests<1||o.guests>12)return'Choose a room type and 1 to 12 guests.'}return''};const t={enabled:!0,bedrooms:11,breakfast:'including full Scottish breakfast',priceNote:'Prices to confirm with the hotel',roomTypes:[{id:'double',name:'Double Room',pricePence:16200},{id:'king',name:'King Room',pricePence:16200},{id:'twin',name:'Twin Room',pricePence:16200},{id:'family',name:'Family Room',pricePence:20500,from:!0}]},n=(t=new Date)=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(t);function r(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const r=new Date(t+'T12:00:00Z');if(!Number.isFinite(+r)||r.toISOString().slice(0,10)!==t)return[];const o='Lunch'===n?720:1080,i='Lunch'===n?0===r.getUTCDay()?870:840:1260;return Array.from({length:(i-o)/15+1},(t,n)=>{const r=o+15*n;return`${String(Math.floor(r/60)).padStart(2,'0')}:${String(r%60).padStart(2,'0')}`})}},1262,[]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.greensideSlots=o,e.greensideRequestError=i,Object.defineProperty(e,"slotsForVenue",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"errorForVenue",{enumerable:!0,get:function(){return u}});var t=r(_d[0]),n=r(_d[1]);function o(n){if(!/^\d{4}-\d{2}-\d{2}$/.test(n))return[];const o=new Date(n+'T12:00:00Z');if(!Number.isFinite(+o)||o.toISOString().slice(0,10)!==n)return[];const i=t.GREENSIDE_KITCHEN_HOURS[o.getUTCDay()];if(!i)return[];const s=t=>60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1263,[1264,1262]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GREENSIDE_KITCHEN_HOURS",{enumerable:!0,get:function(){return n}});const n={0:['10:00','20:00'],1:null,2:null,3:['10:00','20:00'],4:['10:00','20:00'],5:['10:00','21:00'],6:['10:00','21:00']}},1264,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1265,[1262]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1266,[806,928]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requestSentTitle=function(t,n){return n?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.'}},1267,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1268,[]); __d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1269,[]); -__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1270,[17,385,85,409,777,804,1183,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1271,[813,17,319,378,385,278,85,1243,777,910,845,911,863,804,1019,8,1272]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1272,[]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1273,[17,85,1274,777,858,920,1251,1254,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1274,[17,85,1275,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1275,[1276]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1276,[17,780,1277,1306,1307,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1277,[1278]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1278,[1279,1280,1303,1305]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1279,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1280,[1281,1282,1283,1284,1285,1286,1287,1288,1289,1292,1296,1293,1297]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1281,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1282,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1283,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1284,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1289,[1290]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1293,[1294,1295]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1294,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1295,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1298,[1293]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1299,[1293]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1301,[1293,1281]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1302,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1303,[1304]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1305,[1304]); -__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1306,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1307,[17,780,1308,8]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1308,[]); -__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1309,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1310,[822,13,17,85,1274,777,851,858,804,1273,1254,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1311,[822,13,17,85,1249,777,858,876,851,863,804,1250,1254,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1312,[822,13,17,777,858,876,863,804,1273,1254,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1313,[822,13,17,777,858,876,804,1273,1254,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1314,[13,17,777,863,1140,1315,858,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1315,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1316,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1317,[843,13,17,1238,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1318,[13,17,85,1245,777,845,862,858,804,1270,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1319,[13,17,1320,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1320,[17,85,777,1099,804,1321,1322,8]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1321,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1322,[928,971,1321]); -__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1323,[843,13,17,85,1247,777,845,851,863,858,804,1324,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1324,[17,354,362,219,13,777,851,804,900,1325,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1325,[928,899]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1326,[843,1254,13,17,85,777,845,851,863,858,864,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]})}},1327,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1328,[822,13,17,777,858,805,1254,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1329,[13,17,777,1330,1153,1254,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1330,[812,843,17,85,777,845,851,1153,1331,858,804,8]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1331,[928,899,1153]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1332,[13,17,856,1333,1404,8]); -__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Je}}),_e2.DisplayBoard=function(e={}){const t=(0,ie.useOwner)(e=>e.site);return(0,te.useRestaurant)(t)?(0,qe.jsx)(at,{...e}):(0,qe.jsx)(U.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:se.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,qe.jsx)(Y.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),Se=_r(_d[76]),ve=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]);const Ye='#221C12',Qe='#2E2618',Je=12e4,Xe={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},Ze={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},et={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},tt=e=>(e??'').replace(' (example)',''),st=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),lt=e=>e.slotTime?(0,ee.hm)(new Date(e.slotTime)):'ASAP';function it({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,qe.jsxs)(U.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,qe.jsx)(U.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,qe.jsxs)(U.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,qe.jsx)(Y.T,{size:s?24:19,weight:"semibold",colour:e.alert?se.colours.amber:se.colours.text,children:e.value}),(0,qe.jsx)(Y.T,{size:s?14:12,colour:se.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,qe.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,qe.jsx)(U.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,qe.jsx)(Y.T,{size:14,colour:se.colours.muted,children:"No Covers yet"}):(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",colour:se.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,qe.jsx)(Y.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,qe.jsxs)(U.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:se.colours.gold},children:[(0,qe.jsx)(U.default,{style:{width:`${l.walkInPct}%`,backgroundColor:se.colours.gold}}),(0,qe.jsx)(U.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function nt({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,qe.jsxs)(F.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,qe.jsx)(U.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,qe.jsx)(Y.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?se.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,qe.jsx)(Y.T,{size:12,colour:se.colours.muted,children:s}):null]})}function ot({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ve.statusBlock)(e,t,(0,Ve.linkedBooking)(e,l));return e.length?(0,qe.jsx)(U.default,{style:{gap:8},children:e.map(e=>(0,qe.jsxs)(U.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:se.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?se.colours.ok:e.allergies.length?se.colours.red:se.colours.gold},children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:s?16:18,weight:"bold",children:[lt(e)," \xb7 ",tt(e.customerName)]}),(0,qe.jsx)(Y.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,qe.jsxs)(Y.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,Z.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,qe.jsx)(Fe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,qe.jsxs)(Y.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,qe.jsx)(Y.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>te.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,qe.jsx)(Y.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,qe.jsx)(Y.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>te.repo.orders.setStatus(e.id,'collected',t)}):null,(0,qe.jsx)(Ce.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,qe.jsx)(Y.Muted,{children:"No takeaway orders right now."})}function at({embedded:e=!1,boardW:b,headerExtra:Z,subHeader:Fe,noVoice:Ve=!1}={}){const lt=(0,K.default)(),at=b??lt.width,dt=lt.height,ct=at<700,ut=at>=dt,ht=!ct&&ut&&at>=600,gt=ht,bt=Math.round(Math.min(520,Math.max(at>=1e3?448:280,.3*at))),yt=P.default.useRef(null),pt=P.default.useRef(0),[ft,xt]=(0,H.useState)({w:0,h:0}),mt=(0,ie.useOwner)(e=>e.site),jt=(0,te.useRestaurant)(mt);(0,Re.useAlertWatcher)(mt,{enabled:!e});const wt=(0,te.useOrders)(mt),It=(0,te.useBookings)(mt),kt=(0,te.useEvents)(mt),Dt=(0,te.useStore)(e=>e.skipMinutes),St=(0,te.useStore)(e=>e.clock.mode),vt=(0,te.useNow)(5e3),Ct=(0,ie.useOwner)(e=>e.staff),Tt=(0,ie.useOwner)(e=>e.attendance),Rt=(0,ie.useOwner)(e=>e.shifts),$t=(0,ie.useOwner)(e=>e.leave),Bt=P.default.useMemo(()=>(0,Ee.workingShifts)(Rt,$t),[Rt,$t]);P.default.useEffect(()=>{(0,oe.ensureAttendance)((0,ee.ymd)(vt),vt)},[(0,ee.ymd)(vt)]);const Wt=(0,R.useSession)(e=>e.meId),Lt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:tt(Ct.find(e=>e.id===Wt)?.name)}),zt=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:zt,!0);const Ht=(0,ee.ymd)(vt),Pt=(0,A.useTravelDay)('display',Ht),Mt=(0,ne.useFrontDoor)(Ht,ut),At=(0,ae.useDisplaySettings)(mt),Ot=At.privacy,Et=(0,pe.useSaverSync)(),Nt=(0,ae.usePlan)(mt),_t=(0,ae.useFloor)(e=>e.live[mt]),Gt=(0,$e.useBlocks)(e=>e.blocks),[Ft,Vt]=(0,H.useState)('plan'),[Ut,Kt]=(0,H.useState)(!1),[qt,Yt]=(0,H.useState)('all'),[Qt,Jt]=(0,H.useState)(null),[Xt,Zt]=(0,H.useState)(null),[es,ts]=(0,H.useState)(null),[ss,ls]=(0,H.useState)(!1),[is,ns]=(0,H.useState)(!1),[os,as]=(0,H.useState)(null),[rs,ds]=(0,H.useState)(!1),[cs,us]=(0,H.useState)(!1),[hs,gs]=(0,H.useState)(!1),[bs,ys]=(0,H.useState)(!1),[ps,fs]=(0,H.useState)(null),[xs,ms]=(0,H.useState)(null),[js,ws]=(0,H.useState)(null),[Is,ks]=(0,H.useState)(!1),Ds=P.default.useRef(0),Ss=e=>{Ds.current=Date.now(),ws(e)};P.default.useEffect(()=>{if(!js)return;const e=setInterval(()=>{Date.now()-Ds.current>=ze.DAY_IDLE_MS&&ws(null)},5e3);return()=>clearInterval(e)},[js]);const vs=(0,te.useWaitlist)(mt),Cs=(0,te.useStore)(e=>e.walkIns[mt]??0),[Ts,Rs]=(0,H.useState)(!1),[$s,Bs]=(0,H.useState)(!1),[Ws,Ls]=(0,H.useState)(!1),[zs,Hs]=(0,H.useState)(!1);(0,J.useReviewAlerts)(mt);const[Ps,Ms]=(0,H.useState)({view:0,content:0}),[As,Os]=(0,H.useState)(null);P.default.useEffect(()=>{As&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:As,timeoutMs:4500,big:!0,testID:'floor-toast'}),Os(null))},[As]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Es,Ns]=(0,H.useState)(null),_s=P.default.useRef(0),[Gs,Fs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Es)return;_s.current=Date.now();const e=setInterval(()=>{const e=Date.now()-_s.current;if(e>=Je)return Ns(null),void Os('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Fs(e>=105e3?Math.ceil((Je-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Es]);const Vs=e=>e.date!==Ht?ts({title:`Guest details \xb7 ${(0,ze.dayWord)(e.date,Ht)} ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[!e.walkIn&&e.date>Ht?(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,ze.dayWord)(e.date,Ht)}, ${e.time}`,disabled:!wi.ok,accessibilityHint:wi.hint,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ts({title:`Guest details \xb7 ${e.time}`,body:(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(rt,{rid:mt,id:e.id,turnBase:jt.settings.turnMins}),e.walkIn?null:(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ts(null),as(e.id)},style:{minHeight:56}}),e.walkIn?(0,qe.jsx)(we.CancelWalkInButton,{rid:mt,b:e,big:!0,onDone:e=>{ts(null),Os(e)}}):null,e.walkIn?(0,qe.jsx)(we.ReinstateWalkInButton,{rid:mt,b:e,today:Ht,onDone:e=>{ts(null),Os(e)}}):null,(0,Se.bookingDetails)(e)]})}),Us=It.filter(e=>e.date===Ht).sort((e,t)=>e.time.localeCompare(t.time)),Ks=Us.filter(e=>!['cancelled','noshow'].includes(e.status)),qs=wt.filter(st).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Ys=(0,H.useMemo)(()=>(0,c.forecastToday)(jt,It,wt,kt,vt),[jt,It,wt,kt,vt.getTime()/6e4|0]),Qs=(0,$e.closedAreasAt)(Gt,mt,Ht,(0,ee.hm)(vt)),Js=[...Qs].join(','),Xs=(0,H.useMemo)(()=>(0,re.floorView)(Nt,It,wt,_t??{},vt,jt.settings.turnMins,Qs),[Nt,It,wt,_t,vt.getTime(),Js]),Zs=(0,De.hoursFor)(jt,vt),el=Zs?.open??new Date(`${Ht}T12:00:00`),tl=Zs?.close??new Date(`${Ht}T21:00:00`),sl=(0,ee.addMins)(el,-el.getMinutes()),ll=(0,ee.addMins)(tl,30),il=e=>new Date(`${Ht}T${e}:00`),nl=(0,$e.blocksOn)(Gt,mt,Ht).map(e=>({from:il(e.from),to:il(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(jt,vt,Ht)),ol=Object.keys(Xs).filter(e=>'blocked'===Xs[e]?.status),al=js&&js!==Ht?js:Ht,rl=al!==Ht,dl=(0,ze.dayWord)(al,Ht),cl=/^(Today|Yesterday|Tomorrow)$/.test(dl),ul=rl?(0,ze.bookingsForDay)(It,al,Ht).sort((e,t)=>e.time.localeCompare(t.time)):Us,hl=(0,ee.parseYmd)(al);hl.setHours(12);const gl=rl?(0,De.hoursFor)(jt,hl):Zs,bl=gl?.open??new Date(`${al}T12:00:00`),yl=gl?.close??new Date(`${al}T21:00:00`),pl=e=>new Date(`${al}T${e}:00`),fl=[...rl?(0,$e.blocksOn)(Gt,mt,al).map(e=>({from:pl(e.from),to:pl(e.to),label:e.reason??'Paused'})):nl,...rl?(0,n.queuedServicePauses)(jt,hl,al):[]],xl=(0,n.queuedServiceSessions)(jt,hl),ml=l.IS_QUEUED_VENUE&&(void 0===xl||!xl.length),jl=(0,qe.jsxs)(U.default,{testID:"queued-hours-gate",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:void 0===xl?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,qe.jsx)(Y.Muted,{children:i.queuedVenues[mt]?.hours.note})]}),wl=rl?gl||ul.length?alrl?(0,re.dayFloorView)(Nt,ul,al):Xs,[rl,Nt,ul,al,Xs]),[kl,Dl]=(0,H.useState)(null),[Sl,vl]=(0,H.useState)(null),[Cl,Tl]=(0,H.useState)(!1),[Rl,$l]=(0,H.useState)(null),Bl=rl?ul.filter(e=>!['cancelled','noshow'].includes(e.status)):Ks,Wl=Bl.reduce((e,t)=>e+t.partySize,0),Ll=(0,u.coversSplit)(Bl,al),zl=(0,Pe.cancelledDayTally)(It,al),Hl=(0,Me.cancellationsFor)(It,al,e=>e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)','')),Pl=(0,Pe.cancelledTallyWords)(zl,cl?dl.toLowerCase():rl?`on ${dl}`:'today'),Ml=Gt.filter(e=>e.rid===mt&&e.date===al&&!e.removedAt),Al=60*bl.getHours()+bl.getMinutes(),Ol=60*yl.getHours()+yl.getMinutes(),El=(0,Le.chartBands)(Ml,Al,Ol),Nl=(0,Le.seasonClosedAreaIds)(Ml,Al,Ol),_l=Nl.size?{...Nt,areas:Nt.areas.filter(e=>!Nl.has(e.id)),tables:Nt.tables.filter(e=>!Nl.has(e.areaId))}:Nt,Gl=rl?[]:ol.filter(e=>!Nl.has(Nt.tables.find(t=>t.name===e)?.areaId??'')),Fl=new Set((0,Le.blockedHours)(El)),Vl=vt.getHours()+(vt.getMinutes()>=30?1:0),Ul=Ys.hours.filter(e=>e.hour>=Vl&&!Fl.has(e.hour)),Kl=Ul.reduce((e,t)=>e+t.coversHigh,0),ql=Ul.reduce((e,t)=>e+t.coversLow,0),Yl=Math.round((ql+Kl)/2),Ql=!Ys.example&&Ys.open&&Ys.enough&&Kl>0?`Usually ${(0,c.coversRange)(Yl,Yl)} more`:void 0,Jl=async(e,t)=>{const s=Xs[e]?.booking;if(!s||e===t)return;const l=Xs[t]?.status;if(l&&!['free','soon'].includes(l))return void Os('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${re.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,Ie.guardBookingChange)(Os,{b:s,tables:[t]}))return;await te.repo.bookings.update(s.id,{table:t});const i=_t?.[e]?.stage;ae.useFloor.getState().setLive(mt,t,{stage:i??'seated',dirty:!1}),ae.useFloor.getState().setLive(mt,e,{stage:void 0,dirty:!0}),Os(`Saving: ${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,Ie.reportBookingSave)(s.id,`${(0,fe.privName)(s,Ot)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,fe.privName)(s,Ot)} to ${(0,d.tableNumbers)(t)}`,Os)},Xl=e=>{if(xs)return vl(null),void ms(t=>t?{...t,tables:(0,ke.toggleTable)(t.tables,e)}:t);rl?Dl(e):Xt?(e!==Xt&&Jl(Xt,e),Zt(null)):Jt(e)},Zl=xs?It.find(e=>e.id===xs.id):void 0,ei=xs&&Zl?(()=>{const e=Zl.walkIn?(0,fe.privName)(Zl,Ot):tt(Zl.name),t=(0,ke.seatsOf)(Nt,xs.tables).total,s=(0,ke.seatLine)(t,Zl.partySize),l=(0,ke.pickClashes)(Zl,xs.tables,It.filter(e=>e.date===Zl.date),jt.settings.turnMins),i=(0,ke.tableKey)(xs.tables)!==(0,ke.tableKey)((0,ae.tablesOf)(Zl.table));return(0,qe.jsxs)(U.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:se.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,padding:10},children:[(0,qe.jsxs)(U.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,ze.dayWord)(Zl.date,Ht)} ${Zl.time}. Tap tables on the plan to add or take them off. ${(0,ke.tablesWords)(xs.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",colour:se.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,ze.dayWord)(Zl.date,Ht)," ",Zl.time]}),(0,qe.jsxs)(Y.T,{size:16,colour:se.colours.text,children:[(0,ke.tablesWords)(xs.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,qe.jsx)(U.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:(0,qe.jsx)(Y.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Cl&&Zl&&xs.tables.length?(0,qe.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,xs.tables.join('+')),onYes:()=>{Tl(!1),(async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,s,e,t,Os)})()},onNo:()=>Tl(!1)}):null,(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,ke.tablesWords)(xs.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!Zl)return void ms(null);if(!(0,Ie.guardBookingChange)(Os,{b:Zl,tables:xs.tables}))return vl(null),void ms(null);const s=(0,ke.overCapacityAsk)(xs.tables,t,Zl.partySize);if(s&&!Sl)return void vl(s);if('finished'===Zl.status&&xs.tables.length&&!Cl)return void Tl(!0);vl(null),Tl(!1);const l=xs.tables;ms(null),await(0,Ie.saveTablesReported)(mt,Zl,l,e,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{vl(null),ms(null)}})]})]})})():null,ti=_l.areas.filter(e=>_l.tables.some(t=>t.areaId===e.id)),si=e=>{const t=Nt.tables.filter(t=>t.areaId===e);return rl?`${t.filter(e=>!Il[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Xs[e.name]?.status??'free')).length}/${t.length} free`},li='all'===qt||ti.some(e=>e.id===qt)?qt:'all',ii=e=>(0,qe.jsx)(de.FloorCanvas,{plan:_l,areaId:e,mode:"live",fit:"contain",crop:!0,fill:ht,big:!0,view:Il,privacy:Ot,turnBase:jt.settings.turnMins,highlight:xs?xs.tables:Xt?[Xt]:void 0,onTap:e=>Xl(e.name),onDrop:(e,t)=>xs||rl?void 0:Jl(e.name,t.name)}),ni=ct?1:ut||ti.length>2?2:1,oi=e=>{const t=Nt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ai=[];for(let e=0;e{const t=(0,de.areaBounds)(Nt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,de.minReadableScale)(Nt,e.id)}}),ft.w,ft.h):null,di=e=>(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',height:ce.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:si(e.id)})]}),ci=(0,qe.jsx)(U.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-ft.w)>1||Math.abs(s-ft.h)>1)&&xt({w:t,h:s})},children:ri?(0,qe.jsx)(V.default,{style:{flex:1},scrollEnabled:ri.scroll,showsVerticalScrollIndicator:ri.scroll,contentContainerStyle:{gap:ce.GRID_GAP},children:ri.rows.map((e,t)=>(0,qe.jsx)(U.default,{style:{height:ri.rowHeights[t],flexDirection:'row',gap:ce.GRID_GAP},children:e.map(e=>{const t=ti.find(t=>t.id===e);return(0,qe.jsxs)(U.default,{testID:`area-cell-${e}`,style:{width:ri.cellW,gap:2},children:[di(t),(0,qe.jsx)(U.default,{style:{flex:1},children:ii(e)})]},e)})},t))}):null}),ui=(0,qe.jsxs)(U.default,{testID:"venue-plan",style:{flex:ct?void 0:1,gap:10,minWidth:0},children:[(0,qe.jsx)(r.TableNumberWarning,{plan:Nt}),Nt.tables.length?null:(0,qe.jsxs)(U.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,qe.jsx)(Y.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,qe.jsx)(Y.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,qe.jsx)(Y.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,qe.jsx)(nt,{chipId:"all",compact:!ct,label:"Whole venue",selected:'all'===li,onPress:()=>Yt('all')},"__all"),...ti.map(e=>(0,qe.jsx)(nt,{chipId:e.id,compact:!ct,label:`${e.name}${(0,ue.areaMarks)(e)}`,colour:(0,se.brandColour)(e.colour),sub:ct?Qs.has(e.id)?'closed':li===e.id?si(e.id):void 0:void 0,selected:li===e.id,onPress:()=>Yt(e.id)},e.id))];return ct?(0,qe.jsx)(U.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,qe.jsx)(V.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;Ms(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>Ms(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ps.view>0&&Ps.content>0&&Ps.content<=Ps.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ps.view>0&&Ps.content<=Ps.view+1?'100%':void 0},children:e})})(),(0,qe.jsx)(g.FloorLegend,{}),ei,Xt?(0,qe.jsxs)(Y.Row,{gap:8,style:{backgroundColor:se.colours.goldTint,borderRadius:10,padding:8},children:[(0,qe.jsxs)(Y.T,{weight:"semibold",colour:se.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Xt),": tap the new table."]}),(0,qe.jsx)(Y.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Zt(null)})]}):null,'all'===li&&ht?ci:'all'===li?(0,qe.jsx)(U.default,{style:{flex:ct?void 0:1,gap:12,minHeight:gt?void 0:360},children:ai.map((e,t)=>(0,qe.jsxs)(U.default,{style:{flex:ct?void 0:Math.max(.3,...e.map(e=>oi(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,qe.jsxs)(U.default,{style:{flex:1,gap:2},children:[ct?(0,qe.jsxs)(U.default,{style:{alignItems:'center',gap:4},children:[(0,qe.jsxs)(Y.T,{center:!0,size:18,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{center:!0,size:14,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{center:!0,children:si(e.id)})]}):(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between'},children:[(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:(0,se.brandColour)(e.colour),children:[e.name,(0,ue.areaMarks)(e)]}),Qs.has(e.id)?(0,qe.jsx)(Y.T,{size:13,weight:"semibold",colour:se.colours.blue,children:"Closed for weather"}):(0,qe.jsx)(Y.Muted,{children:si(e.id)})]}),(0,qe.jsx)(U.default,{style:ct?{height:Math.max(280,Math.round((at-40)*oi(e.id)))}:{flex:1},children:ii(e.id)})]},e.id)),e.length{if(rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},al)}),gi='timeline'===Ft,bi=Ut?(0,qe.jsx)(_.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Kt(!1),supportedOrientations:['landscape','portrait'],children:(0,qe.jsxs)(U.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:se.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,qe.jsx)(F.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Kt(!1),style:{minHeight:64,minWidth:at<600?120:180,paddingHorizontal:at<600?14:22,borderRadius:16,borderWidth:2,borderColor:se.colours.goldLight,backgroundColor:se.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,qe.jsx)(U.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,qe.jsx)(Y.T,{size:22,weight:"semibold",colour:se.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${rl?(0,ze.dayLong)(al):'Today'}`})}),at<600?null:(0,qe.jsx)(U.default,{style:{minWidth:180}})]}),ml?jl:(0,qe.jsx)(U.default,{style:{flex:1,minHeight:0},children:(0,qe.jsx)(be.Timeline,{hideNow:!0,fit:!0,plan:_l,bookings:rl?ul:Us,now:rl?bl:vt,privacy:Ot,turnBase:jt.settings.turnMins,t0:rl?(0,ee.addMins)(bl,-bl.getMinutes()):sl,t1:rl?(0,ee.addMins)(yl,30):ll,pauses:rl?fl:nl,blockedTables:Gl,onOpen:e=>{if(Kt(!1),rl)return void fs(e.id);const t=(0,ae.tablesOf)(e.table)[0];t&&Xs[t]?Jt(t):Vs(e)}},`full-${al}`)})]})}):null,yi=rl?(0,qe.jsxs)(U.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:se.colours.gold,backgroundColor:se.colours.goldTint},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:cl?`Showing ${dl} \xb7 ${(0,ee.niceDate)((0,ee.parseYmd)(al))}`:`Showing ${(0,ze.dayWord)(al,Ht)}`}),(0,qe.jsx)(U.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Pl}. Showing ${(0,ze.dayLong)(al)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,qe.jsx)(Y.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ms(null),Ss(null)},style:{minHeight:44}})]}):null,pi=(0,qe.jsx)(U.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ct?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(gi||Ut);return(0,qe.jsx)(F.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Vt('plan'),Kt(!0)):(Kt(!1),Vt('plan'))},style:{flex:ct?1:void 0,minHeight:ct?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?se.colours.gold:'transparent',...Ne.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,qe.jsx)(Y.T,{size:ct?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),fi='display'===k.APP_VARIANT&&!e,xi='display'===k.APP_VARIANT&&!e,mi=!e&&!k.IS_CAR&&!ct,ji=fi?(0,qe.jsxs)(U.default,{testID:"display-view-row",style:{flexDirection:ct?'column':'row',flexWrap:ct||mi?'nowrap':'wrap',gap:6,alignItems:ct||mi?'stretch':'center'},children:[pi,(0,qe.jsx)(I.DisplayRotaKitchenButtons,{phone:ct,fill:mi,shifts:Rt,staff:Ct,today:Ht,leave:$t})]}):pi,wi=(0,h.useBookingWrite)(),Ii=e=>(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Walk-in",onPress:Mt.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"New booking",onPress:Mt.openBooking,testID:"add-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint}),(0,qe.jsx)(_e.BigAction,{premium:!0,label:"Edit booking",onPress:()=>ns(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!wi.ok,accessibilityHint:wi.hint})]});(0,Ke.useDisplayNotices)(mt,!e);const ki=!e&&!k.IS_CAR&&!ct,Di=ct?180:202,[Si,vi]=(0,H.useState)(ct?180:168),Ci=P.default.useRef(ct?180:168),Ti=P.default.useRef(null),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(!1),[Wi,Li]=(0,H.useState)(!1),zi=!ct&&dt<=800,Hi=We.DAY_GRAPH_CHROME+(zi?24:8),Pi=P.default.useRef(0),[Mi,Ai]=(0,H.useState)(Hi),[Oi,Ei]=(0,H.useState)(!0),[Ni,Gi]=(0,H.useState)(!1);P.default.useEffect(()=>{Gi(!1)},[at,dt]);const Fi=P.default.useRef(()=>{}),Vi=P.default.useCallback(e=>{Math.abs(e-Pi.current)>=2&&(Pi.current=e,setTimeout(()=>Fi.current(),0))},[]),Ui=()=>{const e=Ti.current,t=Ri.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=t>Ci.current?Math.ceil(t-Ci.current):0,o=ki?Math.max(Hi,Pi.current):Math.max(Hi,n);ki&&o!==Mi&&Ai(o);const a=!ct&&dt>=700?140:70,r=Math.floor(s-4-e)-o-l,d=i>0&&r-i>=a;ki&&d!==Oi&&Ei(d),ki&&!Ni&&r<48&&Gi(!0);const c=r-(d?i:0),u=Math.min(Di,c>=a?Math.max(a,c):Math.max(0,c));Math.abs(Ci.current-u)>=2&&(Ci.current=u,vi(u))},l=44+(dt<820?4:8),i=46+(dt<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=$i.current;ki&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=dt<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Bi.current?44+d:0)}):s(n,a,t,ki?i:l)})})};Fi.current=Ui,P.default.useEffect(()=>{const e=setTimeout(()=>Fi.current(),60),t=setTimeout(()=>Fi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[at,dt,al]);const Ki=(0,qe.jsxs)(U.default,{ref:Ri,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ui()},style:{flexDirection:'row',flexWrap:at>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ct?12:zi?2:6,justifyContent:ct?'center':void 0,borderTopWidth:1,borderTopColor:se.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,qe.jsx)(Ue.DisplayClockButton,{}),(0,qe.jsx)(ge.HoldToEdit,{quiet:!0,onUnlock:()=>{Fs(null),Ns({at:Date.now()})},onHint:()=>Os('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,qe.jsx)(Be.BlockBookingsButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,display:!0,day:al}),Nt.areas.some(e=>e.outdoor)?(0,qe.jsx)(Be.CloseGardenButton,{rid:mt,r:jt,now:vt,by:Lt,quiet:!0,short:!0}):null,(0,qe.jsx)(F.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Hs(!0),style:({pressed:e})=>({...Ne.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,qe.jsx)(Y.T,{size:15,weight:"semibold",colour:se.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,qe.jsx)(f.GiftQrButton,{rid:mt,venue:jt.name})]}),qi=qs.length?(0,qe.jsxs)(U.default,{testID:"takeaway-panel",style:[Ne.look.panel,{overflow:'hidden'}],children:[(0,qe.jsxs)(Y.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,qe.jsx)(Y.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,qe.jsxs)(Y.T,{size:12,colour:se.colours.muted,children:[qs.length," live"]})]}),(0,qe.jsx)(U.default,{style:{padding:10},children:(0,qe.jsx)(ot,{list:qs,me:Lt,compact:!0,bookings:It})})]}):null,Yi=(Oe.DueToday,jt.settings.turnMins||90),Qi=rl?ul:(0,S.todaysGuestList)(Us,vt,Yi),Ji=rl?[]:(0,S.todaysFinishedList)(Us,vt,Yi),Xi=rl?cl?`${dl}\u2019s guests`:`Guests ${dl}`:'Today\u2019s guests',Zi=(0,qe.jsxs)(qe.Fragment,{children:[0===Qi.length?(0,qe.jsx)(Y.Muted,{children:rl?al{const t=(0,S.isLeftEarly)(e,vt,Yi),s=(0,le.isSeatedHighlight)(e.status,{otherDay:rl})&&!t,l=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=se.colours.text,n=s?se.colours.goldLight:se.colours.muted,o=se.colours.gold,a=l.depositWarn?se.colours.amber:se.colours.goldLight;return(0,qe.jsxs)(F.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:rl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,le.seatedHighlightStyle)({backgroundColor:e?Qe:Ye,borderColor:se.colours.gold,borderLeftColor:se.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,qe.jsx)(Y.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,qe.jsx)(U.default,{style:{paddingTop:2},children:(0,qe.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:se.colours.amber,ink:se.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,qe.jsx)(Y.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&re.OCCASION_ICON[l.occasion]?(0,qe.jsx)(Y.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:re.OCCASION_ICON[l.occasion]}):null]}),(0,qe.jsxs)(Y.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,qe.jsx)(Y.T,{size:16,colour:i,children:l.people}),l.deposit?(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,qe.jsx)(Y.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,qe.jsx)(Y.T,{size:16,colour:n,children:" \xb7 "}),(0,qe.jsx)(Y.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,qe.jsx)(Y.T,{size:16,children:" "}):null,l.dog?(0,qe.jsx)(U.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,qe.jsx)(me.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,qe.jsx)(Y.T,{size:15,colour:se.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),Ji.length?(0,qe.jsxs)(U.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,padding:8,gap:4},children:[(0,qe.jsxs)(F.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${Ji.length}${bs?', expanded':', collapsed'}`,accessibilityState:{expanded:bs},onPress:()=>ys(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(Y.T,{size:16,weight:"semibold",colour:se.colours.goldLight,children:["Finished (",Ji.length,")"]}),(0,qe.jsx)(Y.T,{size:16,colour:se.colours.muted,children:bs?'\u25be':'\u25b8'})]}),bs?Ji.map(e=>{const t=(0,xe.guestRowText)(e,{name:e.walkIn?(0,fe.privName)(e,Ot):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,qe.jsxs)(F.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{gs(!1),fs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:se.colours.hairline,backgroundColor:e?se.colours.tilePressed:'transparent'}),children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",colour:se.colours.gold,style:{width:58},children:t.time}),(0,qe.jsx)(Y.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,qe.jsxs)(Y.T,{size:15,colour:se.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,qe.jsx)(U.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,qe.jsx)(v.BookingUndo,{b:e,rid:mt,today:Ht,who:t.name,allowed:wi.ok})})]},e.id)}):null]}):null,(0,qe.jsx)(Ae.CancellationsSection,{items:Hl,dayWord:rl?cl?dl.toLowerCase():`on ${dl}`:'today'})]}),en=(0,qe.jsx)(V.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:Zi}),tn=G.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&gs(!1)}}),sn=(0,qe.jsxs)(F.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${Xi}, ${Qi.length}`,accessibilityState:{expanded:hs},'aria-expanded':hs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>gs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:hs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?se.colours.tilePressed:hs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,qe.jsx)(Y.T,{size:16,weight:"bold",colour:se.colours.gold,children:Qi.length}),(0,qe.jsx)(U.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(U.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,qe.jsxs)(Y.T,{size:13,weight:"semibold",colour:se.colours.goldLight,numberOfLines:1,children:[Xi," ",hs?'\u2039':'\u203a']})})})]}),ln=Math.min(560,Math.max(320,.44*at))<400,nn=hs?(0,qe.jsxs)(U.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,qe.jsxs)(U.default,{testID:"guests-drawer",...tn.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*at)),backgroundColor:se.colours.surface,borderRightWidth:1,borderColor:se.colours.gold,borderRadius:14,...Ne.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,qe.jsxs)(U.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,qe.jsxs)(U.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsxs)(U.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,qe.jsxs)(Y.T,{testID:"guests-heading",size:ln?14:17,weight:"semibold",colour:se.colours.gold,style:{flexShrink:1,minWidth:0},children:[Xi.toUpperCase()," (",Qi.length,")"]}),(0,qe.jsx)(F.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:cs},'aria-expanded':cs,onPress:()=>us(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:ln?8:12,borderRadius:12,borderWidth:1,borderColor:cs?se.colours.gold:se.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?se.colours.tilePressed:cs?se.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,qe.jsxs)(Y.T,{size:14,weight:"semibold",colour:se.colours.goldLight,children:[ln?'Key':'Guest key'," ",cs?'\u25b4':'\u25be']})})]}),(0,qe.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${Xi}`,onPress:()=>gs(!1),style:{marginRight:-6,flexShrink:0}})]}),zl.count?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,testID:"cancelled-day-tally-guests",children:Pl}):null,cs?(0,qe.jsxs)(U.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:se.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,qe.jsxs)(U.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,qe.jsxs)(U.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(Y.T,{size:16,children:e}),(0,qe.jsx)(Y.T,{size:14,children:t})]},t))]}):null]}),en]}),(0,qe.jsx)(F.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${Xi}`,accessibilityRole:"button",onPress:()=>gs(!1),style:{flex:1}})]}):null,on=ml?jl:l.IS_KIRKTON&&!Object.values(jt.kitchenHours??{}).some(Boolean)?(0,qe.jsxs)(U.default,{testID:"kirkton-hours-to-confirm",style:[Ne.look.panel,{padding:14,gap:8}],children:[(0,qe.jsx)(Y.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,qe.jsx)(Y.Muted,{children:"No service hours have been set for this venue."})]}):(0,qe.jsx)(We.DayGraph,{busyThreshold:(0,t.venueBusy)(jt,It,vt).busy,todays:ul,open:bl,close:yl,now:vt,turnBase:jt.settings.turnMins,blocks:Ml,pauses:fl,compact:ct,dense:!ct,fit:ht,tight:ht&&dt<=600,height:ht?Si:Di,forecastNote:rl?void 0:Ql,emptyText:wl,past:al{Ds.current=Date.now(),ks(!0)},shortDay:!ct&&at<1100}),dn=(0,qe.jsx)(He.DisplayCalendar,{visible:Is,today:Ht,day:al,bookings:It,restaurant:jt,now:vt,onDay:Ss,onClose:()=>ks(!1)}),cn=()=>{rl?gs(!0):Kt(!0)},un=(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',padding:zi?4:dt<820?8:12,paddingTop:zi?ki?2:4:dt<820?ki?4:6:ki?8:10,gap:zi?8:12,minHeight:0,overflow:'hidden'},children:[Pt?null:sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Pt?null:yi,Pt?(0,qe.jsx)(V.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"})}):gi?hi:ui,bi,nn]}),(0,qe.jsxs)(U.default,{testID:"display-side",style:{width:bt,gap:dt<820?4:8,minHeight:0},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:Ii(!1)}),(0,qe.jsx)(U.default,{style:{flexShrink:0},children:ji}),Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",onLayout:Ui,style:ki&&!Ni?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:dt<820,snug:dt<820,tight:dt<800,fill:ki&&!Ni,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{ref:Ti,testID:"day-graph-slot",onLayout:Ui,style:{flexGrow:0,flexShrink:ki?0:1,flexBasis:(ct?Di:Si)+(ki?Mi:Hi),height:(ct?Di:Si)+(ki?Mi:Hi),minHeight:dt<=600?90:Math.min((ct?Di:Si)+We.DAY_GRAPH_CHROME,!ct&&dt>=768?140+We.DAY_GRAPH_CHROME:120),overflow:'visible'},children:an}),ki&&!Pt?(0,qe.jsx)(U.default,{ref:$i,testID:"display-side-split",onLayout:Ui,style:{flexShrink:0,alignItems:'center'},children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})}):null,(0,qe.jsxs)(V.default,{testID:"display-side-scroll",style:ki?{flexGrow:0,flexShrink:1,minHeight:Wi&&Oi?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Bi.current&&(Bi.current=s,Li(s),setTimeout(Ui,0))},children:[ki||xi?null:(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),qi,(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt})]})]})]});return(0,qe.jsxs)(q.SafeAreaView,{style:{flex:1,backgroundColor:se.colours.bg},onTouchStart:()=>{Ds.current=Date.now()},onMouseDown:()=>{Ds.current=Date.now()},children:[ct?(0,qe.jsx)(U.default,{style:{flex:1},children:(0,qe.jsxs)(V.default,{ref:yt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,qe.jsxs)(U.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,qe.jsx)(U.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,qe.jsx)(j.ExitButton,{})}),(0,qe.jsx)(X.RestaurantLogo,{rid:mt,size:64}),(0,qe.jsx)(Y.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:jt.name}),(0,qe.jsx)(X.PoweredBy,{}),(0,qe.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,qe.jsx)(U.default,{accessible:!0,accessibilityLabel:`Current time ${(0,ee.hm)(vt)}`,children:(0,qe.jsx)(Y.T,{center:!0,size:30,weight:"semibold",colour:se.colours.goldLight,children:(0,ee.hm)(vt)})}),(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:"m"}),(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",size:"m"}),Z]}),Fe,k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt}),rn,(0,qe.jsx)(U.default,{testID:"phone-glance",style:{width:'100%'},children:(0,qe.jsx)(it,{phone:!0,split:Ll,items:[{label:`Tables \xb7 ${dl}`,value:Bl.length,testID:'badge-tables'},{label:`Covers \xb7 ${dl}`,value:Wl,testID:'badge-covers'},{label:'Takeaway',value:qs.length,alert:qs.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>ls(!0)}]})}),(0,qe.jsx)(U.default,{testID:"primary-actions",style:{gap:8},children:Ii(!0)}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),ji,(0,qe.jsxs)(U.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[gi?hi:ui,bi]}),(0,qe.jsxs)(U.default,{onLayout:e=>{pt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[Ne.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,qe.jsxs)(Y.T,{center:!0,size:20,weight:"semibold",colour:se.colours.goldLight,accessibilityRole:"header",children:[Xi," (",Qi.length,")"]}),(0,qe.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:Xi,style:{gap:4},children:Zi})]}),qi,an,(0,qe.jsx)(U.default,{testID:"covers-dock",children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>yt.current?.scrollTo({y:pt.current,animated:!0})})}),(0,qe.jsxs)(U.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,qe.jsx)(Y.T,{center:!0,size:14,colour:Ot?se.colours.muted:se.colours.amber,children:Ot?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,qe.jsx)(Y.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>Rs(!0),style:{minHeight:48,alignSelf:'stretch'}}),xi?null:(0,qe.jsx)(Y.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Bs(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Ki]})}):(0,qe.jsxs)(qe.Fragment,{children:[ki?(0,qe.jsx)(U.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:se.colours.hairline},children:(0,qe.jsx)(U.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,qe.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,qe.jsxs)(U.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:at>=1e3?18:14,paddingVertical:zi?2:dt<820?4:8,gap:8,minHeight:zi&&ki?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),...Ne.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,qe.jsxs)(U.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:ki?16:8,minWidth:0,overflow:'hidden',...ki?{justifyContent:'flex-start'}:null},children:[(0,qe.jsx)(U.default,{testID:"display-header-brand",style:ki?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,qe.jsx)(X.RestaurantBrand,{rid:jt.id,size:at<900?32:40,beside:!0,noLogo:ki})}),(0,qe.jsxs)(U.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,qe.jsx)(Y.T,{size:at<900?18:21,weight:"semibold",colour:se.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,ee.hm)(vt)}),at>=900?(0,qe.jsx)(Y.T,{size:13,colour:se.colours.muted,children:(0,ee.niceDate)(vt)}):null]})]}),Pt?(0,qe.jsx)(U.default,{style:{width:220}}):(0,qe.jsx)(U.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:rn}),(0,qe.jsxs)(U.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,qe.jsxs)(U.default,{testID:"display-header-chips",style:{flexDirection:at>=1400||ki?'row':'column',alignItems:at>=1400||ki?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,qe.jsx)(Ge.ShellfishChip,{rid:mt,by:Lt,app:"display",size:at<1240?'xs':at<1280||dt<700?'s':'m'}),Pt?null:(0,qe.jsx)(Ge.SundayRoastChip,{rid:mt,by:Lt,app:"display",slot:ki,size:at<1340?'xs':at<1400||dt<700?'s':'m'})]}),'simulated'===St?(0,qe.jsx)(F.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>Dt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(Y.T,{size:11,colour:se.colours.muted,children:"+15"})}):null,Z,e?null:(0,qe.jsx)(U.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,qe.jsx)(j.ExitButton,{size:44})})]})]}),Fe,k.IS_CAR||!Pt||ki?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(Ie.BookingSaveBanner,{rid:mt,margin:{marginHorizontal:12,marginTop:6}}),Pt||ki?null:(0,qe.jsx)(U.default,{testID:"display-day-stats",style:Xe,children:(0,qe.jsxs)(U.default,{style:Ze,children:[k.IS_CAR?null:(0,qe.jsx)(w.WhosOnShift,{compact:!0}),(0,qe.jsx)(U.default,{style:et,children:(0,qe.jsx)(it,{splitOnly:!0,split:Ll,items:[]})})]})}),ht?un:(hn=(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(U.default,{testID:"front-door-bar",style:{gap:10},children:[(0,qe.jsx)(U.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:Ii(!1)}),ji]}),(0,qe.jsx)(Be.BlocksBanner,{rid:mt,now:vt,big:!0,by:Lt}),Pt?(0,qe.jsx)(A.DayView,{rid:mt,day:Pt,today:Ht,app:"display"}):(0,qe.jsx)(qe.Fragment,{children:(0,qe.jsxs)(U.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[sn,(0,qe.jsxs)(U.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[yi,gi?hi:ui,bi,nn]})]})}),qi,Pt?null:(0,qe.jsx)(U.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,qe.jsx)(M.CoversToday,{rid:mt,day:al,sound:(0,O.flapSoundOn)(),onPress:cn})}),Pt?null:(0,qe.jsx)(U.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Di+We.DAY_GRAPH_CHROME},children:an})]}),(0,qe.jsx)(V.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:hn})),Ki]}),(0,qe.jsx)($.SoldOutStrip,{rid:mt,by:zt,onOpen:()=>Hs(!0)}),(0,qe.jsx)(B.SoldOutSheet,{visible:zs,onClose:()=>Hs(!1),rid:mt,by:zt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,qe.jsx)(p.TableOrderCue,{rid:mt}),Mt.elements,is?(0,qe.jsx)(y.EditBookingPicker,{rid:mt,today:Ht,who:Lt,onClose:()=>ns(!1)}):null,os?(0,qe.jsx)(y.EditBookingSheet,{rid:mt,id:os,who:Lt,onClose:()=>as(null)}):null,Qt?(0,qe.jsx)(Se.TableSheet,{rid:mt,name:Qt,view:Xs,plan:Nt,todays:Us,now:vt,privacy:Ot,turnBase:jt.settings.turnMins,onClose:()=>Jt(null),onWalkIn:e=>Mt.openWalkInAt(e),onMove:e=>Zt(e),onDetails:Vs}):null,kl?(()=>{const e=Il[kl],t=e?.dayBookings??[];return(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>{$l(null),Dl(null)},title:`${(0,d.tableNumbersA11y)(kl)} \xb7 ${cl?dl:(0,ze.dayLong)(al)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,qe.jsxs)(Y.T,{size:16,center:!0,colour:se.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${cl?dl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${cl?dl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,fe.privName)(e,Ot):tt(e.name);return(0,qe.jsx)(Y.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,ke.tablesWords)((0,ae.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{Dl(null),fs(e.id)},style:{minHeight:56}},e.id)}),al>=Ht?(()=>{const t=e?.table.maxSeats??0,s=It.filter(e=>e.date===al&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,ae.tablesOf)(e.table).includes(kl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,qe.jsxs)(U.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,qe.jsxs)(Y.T,{size:17,weight:"semibold",center:!0,colour:se.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(kl)]}),Rl?(0,qe.jsxs)(U.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Rl.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:se.colours.amber,backgroundColor:se.colours.amberBg},children:[(0,qe.jsx)(Y.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:Rl.ask}),(0,qe.jsxs)(Y.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!wi.ok,accessibilityHint:wi.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=It.find(e=>e.id===Rl.id);if($l(null),!e)return;const s=tt(e.name);Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os)}}),(0,qe.jsx)(Y.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>$l(null)})]})]}):null,Rl?null:s.slice(0,12).map(e=>{const s=tt(e.name),l=e.partySize>t;return(0,qe.jsx)(Y.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!wi.ok,accessibilityHint:wi.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(kl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,Ie.guardBookingChange)(Os,{b:e,tables:[kl]}))return;const l=(0,ke.overCapacityAsk)([kl],t,e.partySize);l?$l({id:e.id,ask:l}):(Dl(null),await(0,Ie.saveTablesReported)(mt,e,[kl],s,t,Os))},style:{minHeight:56}},e.id)})]}):null})():null,(0,qe.jsx)(Y.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{$l(null),Dl(null)},style:{minHeight:56}})]})})():null,ps?(()=>{const e=It.find(e=>e.id===ps);return e?(0,qe.jsx)(je.GuestActionsSheet,{rid:mt,b:e,name:e.walkIn?(0,fe.privName)(e,Ot):tt(e.name),view:Xs,now:vt,otherDay:e.date!==Ht,turnBase:jt.settings.turnMins,onClose:()=>fs(null),onDetails:Vs,onDone:Os,onEdit:e=>{fs(null),as(e.id)},onPickOnPlan:(e,t)=>{gs(!1),Vt('plan'),Yt('all'),ms({id:e.id,tables:t})}}):null})():null,es?(0,qe.jsx)(Se.DetailsPanel,{title:es.title,onClose:()=>ts(null),children:es.body}):null,dn,rs?(0,qe.jsx)(Se.ServiceSummary,{r:jt,todays:Us,orders:wt,waitlistAll:vs,walkInCount:Cs,onClose:()=>ds(!1)}):null,Ts?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Rs(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,qe.jsx)(g.FloorLegend,{}),(0,qe.jsxs)(U.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:se.colours.amber,ink:se.colours.bg}),(0,qe.jsx)(Y.T,{size:14,children:"allergy"})]}),(0,qe.jsxs)(U.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,qe.jsx)(me.DogIcon,{size:18}),(0,qe.jsx)(Y.T,{size:14,children:"dog"})]}),(0,qe.jsx)(Y.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Rs(!1)})]}):null,Ws?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Ls(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,qe.jsx)(F.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{Ls(!1),Bs(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,qe.jsx)(Y.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Ls(!1)})]}):null,$s?(0,qe.jsxs)(Y.Sheet,{visible:!0,onClose:()=>Bs(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,qe.jsx)(Q.ReviewsSection,{rid:mt,mode:"read",venueName:jt.name}),(0,qe.jsx)(Y.Button,{kind:"secondary",label:"Close",onPress:()=>Bs(!1)})]}):null,ss?(0,qe.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>ls(!1),children:[(0,qe.jsx)(Y.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,qe.jsx)(ot,{list:qs,me:Lt,bookings:It})]}):null,Es?(0,qe.jsx)(U.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:se.colours.bg},children:(0,qe.jsx)(he.PlanDesigner,{initial:Nt,venue:jt.name,mode:"display",startStep:"arrange",onActivity:()=>{_s.current=Date.now(),null!==Gs&&Fs(null)},notice:null!==Gs?`Locking again in ${Gs} s \xb7 touch to keep editing`:null,onSave:e=>{ae.useFloor.getState().setPlan(mt,e),Ns(null),Os('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{ae.useFloor.getState().setPlan(mt,e),Os('Live seating plan updated on every screen.')},onCancel:()=>{Ns(null),Os('No changes kept. Editing is locked again.')}},Es.at)}):null,e?null:(0,qe.jsx)(ye.Screensaver,{rid:mt,idleMins:At.idleMins,pinOn:At.pinOn,wake:At,tonightCards:At.tonightCards,cfg:Et}),e?null:(0,qe.jsx)(Ce.PrintHost,{rid:mt}),e?null:(0,qe.jsx)(ve.AlertHost,{variant:"display",rid:mt,skipTakeaway:!0}),e?null:(0,qe.jsx)(E.SeatAllergenReminder,{rid:mt}),e?null:(0,qe.jsx)(Te.TakeawayTakeover,{rid:mt,me:Lt})]});var hn}function rt({rid:e,id:t,turnBase:s}){const l=(0,te.useBookings)(e).find(e=>e.id===t);return l?(0,qe.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1333,[1053,779,805,806,1334,813,1335,1094,843,1140,1336,1337,1338,1091,1122,1339,1340,1345,1346,1203,1347,856,1352,1353,1354,1115,1113,920,1355,1152,891,1104,1356,17,1072,1178,1018,1087,1357,378,363,385,278,85,409,19,777,1230,1234,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1358,1108,1359,1365,1367,1370,1375,1369,1376,1379,1380,1117,1095,1096,862,1385,1219,1386,1229,1221,995,1391,1396,1397,1054,1052,1119,1399,1400,1401,1071,1171,1402,1170,1161,853,1348,1403,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1336,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1337,[996,1057]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1338,[17,85,1076,777,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1339,[843,17,85,777,858,1153,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1340,[17,378,385,409,85,1274,777,1171,779,998,1341,1342,1344,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1341,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1342,[17,378,385,278,395,85,409,779,777,804,1343,1344,8]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1343,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1344,[993,856,1343,928,899]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1345,[831]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1346,[813,17,362,378,385,85,777,1171,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1347,[1167,17,219,385,85,777,1166,804,876,920,1348,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1348,[813,1033,812,880,1171,17,385,85,409,777,804,876,913,863,916,1349,899,840,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1349,[831,928,899,1350,880,1351]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1350,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1351,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1352,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1354,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1355,[813,812,17,219,385,278,85,777,1152,858,891,816,893,894,856,892,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1356,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1357,[17,85,780,804,8]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1358,[]); -__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1359,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1360,1362,1361,998,876,1108,1363,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1360,[813,843,17,1361,85,842,804,777,1109,1362,1110,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1361,[842]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1362,[1361,842]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1363,[17,368,278,85,842,982,1364,804,779,812,777,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1364,[982,993,856,928,899]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1365,[17,219,385,85,804,777,1171,1366,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1366,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:D,turnBase:I,t0:E,t1:z,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,u.clashes)(N,I),[N,I]),U=Math.max(1,Math.ceil((z.getTime()-E.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),oe=(0,b.addMins)(E,15*te),le=(0,b.addMins)(oe,15*J),ie=e=>(e.getTime()-oe.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-E.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[E.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,ue]=(0,i.useState)(null),he=(0,i.useRef)(null);he.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>ue(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(0,i.useRef)(0),fe=(t,o)=>({onClick:()=>{if(Date.now()-me.current<700)return;const e=(0,a.releaseOn)(he.current,t.id,!1,Date.now());if(ue(e.arm),de(''),'select'===e.action)try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(he.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(he.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(he.current,t.id,Date.now()))return;const l=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(l)>=6)&&ne({id:t.id,row:o,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null),me.current=Date.now();const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),h=(0,a.releaseOn)(he.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(ue(h.arm),'select'===h.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void de('');if('none'===h.action)return;de('');const g=P.findIndex(e=>e.key===o),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,o,P[p].key);if(!x||(0,l.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const o=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,u.startOf)(t))}${o?` \xb7 ${o.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,l.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(oe)," to ",(0,b.hm)(le)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const o=4*t*K,l=Math.max(0,Math.min(J*K-56,o-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(o)},pointerEvents:"none",style:{position:'absolute',left:l,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,o)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&o[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&o[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!he.current,onResponderRelease:()=>{ue(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const o=Math.max(0,ie(e.from)),l=Math.min(J*K,ie(e.to));return l<=o?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:o,width:l-o,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,l,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:l>0&&i[l-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,o)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*o*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},o)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,u.startOf)(e)oe)).map(t=>{const l=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,u.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,u.startOf)(t),(0,u.durOf)(t,I)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,I)} min${c?', clash':''}${(0,h.depositView)(t,!0)?`, ${(0,h.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...fe(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(l?l.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:l?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-x pan-y'},l?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,o.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,h.depositView)(t,!0)?d>=150?` \xb7 ${(0,h.depositView)(t,!0).label}`:'Deposit paid'===(0,h.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&ge>=0&&ge<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:ge,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-ge,Math.min(-18,J*K-ge-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{ue(null),D(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{ue(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),o=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1367,[813,843,1095,17,264,219,278,85,1111,858,998,1076,841,863,1096,1368,804,777,1369,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1368,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1369,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1370,[805,813,17,266,319,219,385,85,409,804,857,1371,777,999,916,1345,1373,880,1374,1375,858,863,8,260]); -__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1371,[17,219,85,1372,8]); -__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1372,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1373,[219]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1375,[17,831,928,899,1374]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1376,[843,841,998,1377,1378]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1377,[845]); -__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1378,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1379,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1380,[1381,843,1095,998,17,85,777,1098,858,1116,1376,1096,863,1093,1117,1118,1119,804,1337,1383,1384,1115,1354,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1381,[17,362,385,85,858,920,876,996,1382,856,804,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1382,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1385,[1171,1381,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1369,858,998,845,1089,1076,1315,804,1337,1383,1384,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1386,[812,17,219,385,85,777,858,998,1387,804,1388,1390,8]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1387,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1388,[831,858,998,1387,1389,1390]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1389,[843]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1390,[219,1389]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1391,[843,17,1182,1171,385,85,995,998,862,863,804,777,1392,1395,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1392,[1393,854,843,17,264,378,385,278,85,858,995,998,1394,863,804,1026,777,1395,1349,899,1337,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1393,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1394,[862,863,861]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1395,[805,998,928,899]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1397,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1398,[1076]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1399,[843,1377]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1400,[17,385,85,777,1399,804,1357,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1401,[17,85,884,777,1171,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1402,[17,1171,385,85,409,777,8]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1403,[17,1005,876,926,816,1006,916,1349,1066]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1404,[805,813,857,17,219,385,85,409,899,804,777,1345,1405,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1405,[]); -__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]})}},1406,[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]})}},1407,[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,{})}},1408,[13,17,1409,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1409,[]); -__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]})}},1410,[13,17,856,1411,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)','')}})}},1411,[1412,1416,813,912,1072,1417,1202,1203,1028,1025,1026,1418,1420,1423,1152,891,978,1425,975,880,1031,1032,1426,914,1008,915,17,1154,1230,1234,1196,356,385,278,85,409,19,777,857,876,804,1160,1427,1066,1084,1086,1081,1027,1010,1057,1434,1435,1436,1444,1445,920,219,1235,1175,1181,1441,1195,1192,1450,1178,878,1205,1206,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1412,[812,17,1018,378,85,1108,1109,1359,1391,777,995,998,863,804,1057,999,1413,1414,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1413,[812,17,385,85,777,804,998,805,999,856,899,8]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1414,[17,85,777,998,1415,842,804,1038,928,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1415,[]); -__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']]},1416,[17,85,777,1057,899,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)},1417,[843,17,85,777,845,851,1153,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)}}})]})}},1418,[899,17,264,219,85,1274,777,1251,1254,804,1419,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},1419,[17,219,85,777,1251,8]); -__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}},1420,[17,779,85,777,845,1251,1421,1422,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'},1421,[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()})},1422,[899,1421,1254]); -__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'})})}},1423,[805,1424,17,85,777,851,1251,1252,1253,899,1254,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1424,[]); -__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}},1425,[219,976]); -__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]},1426,[17,85,777,804,914,1022,899,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1427,[805,1424,1095,1261,1428,812,822,1117,1118,1091,1122,1429,1114,1119,1399,1400,1057,1337,996,1120,1089,841,1378,1125,1431,1230,1432,1391,1078,1055,1090,17,85,777,1357,858,845,851,863,1315,804,1177,1098,1115,998,1354,1062,1161,1433,1221,899,1179,1396,862,8]); -__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])},1428,[806,17,85,777,899,1265,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1429,[17,385,85,1430,899,928,804,777,8]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1430,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1431,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1180,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1432,[17,385,1171,777,804,8]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1433,[17,85,864,858,848,804,777,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])},1434,[17,1392,1057,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])},1435,[843,17,85,1161,777,858,845,853,863,804,1177,1057,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})},1436,[820,896,1437,17,219,85,777,816,876,895,1000,897,899,1443,804,880,1162,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1437,[812,891,1140,899,780,1219,1221,17,264,362,219,385,85,409,864,777,858,1230,876,851,863,804,1177,1057,853,1055,1438,1160,1441,1442,1139,1145,1144,1008,839,1142,1148,1214,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1438,[886,779,816,813,822,862,1039,1439,17,909,319,362,219,385,85,777,858,876,863,804,1177,1057,1214,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1439,[482,1440]); -__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}});var t={}},1440,[]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1441,[812,17,1244,1026,854,362,385,85,777,876,851,863,804,1177,1057,1214,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1442,[978,17,385,85,777,876,804,1057,1160,899,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'}},1443,[]); -__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)','')},1444,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1445,[1446,17,219,24,85,856,1447,920,804,1449,777,899,922,880,1069,918,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1446,[]); -__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])},1447,[17,278,85,777,857,804,1448,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(' ')},1448,[]); -__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1449,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1450,[1178,1072,1117,1089,17,385,85,777,876,863,804,1090,1170,1167,1057,1120,1175,1438,1161,860,1179,853,1177,884,1354,998,843,1115,1192,1199,1071,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]})}},1451,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1452,[1453,899,778,1405,1455,995,13,1482,479,17,368,319,219,24,85,805,857,1065,856,1484,19,858,998,876,804,1445,920,988,1487,1488,1028,1104,880,1008,914,1490,1375,8,1491,1492,1493,1494]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1453,[880,812,17,219,366,85,777,1454,899,804,1181,920,876,909,8]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1454,[]); -__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])},1455,[1456,1479,1481]); -__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)}}},1456,[198,1457,1460,1474,1475,1476,1477,1478]); -__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}},1457,[198,1458]); -__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}},1458,[1459]); -__d(function(g,r,i,a,m,e,d){},1459,[]); -__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)}},1460,[1461,198,1457,1474,1475]); -__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]}})})},1461,[1462,1463,1473]); -__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()}})}},1462,[1463,1467,1472]); -__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}}},1463,[198,355,1464,1468,1469,1470,1471,1467,1472]); -__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}},1464,[198,1465,322,263,1466,1467]); -__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])},1465,[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}}},1466,[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},1467,[]); -__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}},1468,[]); -__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}},1469,[]); -__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])},1470,[1468]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1471,[]); -__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},1472,[355,1466]); -__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])},1473,[17,1463]); -__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}},1474,[1461,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])},1475,[1461,1474]); -__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}},1476,[1457]); -__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])},1477,[198,1457,1460,1458]); -__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})({})},1478,[]); -__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]))},1479,[198,37,1480]); -__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')},1480,[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]}},1481,[17,1456]); -__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]}})})},1482,[1483]); -__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(){}},1483,[]); -__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]})}},1484,[17,24,85,409,777,857,920,899,880,805,804,1485,1486,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1485,[]); -__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])},1486,[17,85,777,804,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()})},1487,[905,868,867,899]); -__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1488,[813,779,17,974,385,85,856,899,976,804,777,1345,971,880,1489,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1489,[17,1413,385,85,899,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1490,[]); -__d(function(e,s,o,p,t,a,f){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1491,[]); -__d(function(s,o,e,p,t,c,d){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1492,[]); -__d(function(o,s,e,f,p,t,d){"use strict";p.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1493,[]); -__d(function(o,s,p,t,d,e,n){"use strict";d.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1494,[]); -__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]})}},1495,[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},1496,[1497]); -__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},1497,[8,1498,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}))}}},1498,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1499,[]); -__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})}}},1500,[8,482,17,253,634]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){return null}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}})},1270,[]); +__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,"LAUNCHER_LINE",{enumerable:!0,get:function(){return b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1271,[17,385,85,409,777,804,1184,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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t,signedOff:!1}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1272,[813,17,319,378,385,278,85,1244,777,910,845,911,863,804,1019,8,1273]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1273,[]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1274,[17,85,1275,777,858,920,1252,1255,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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1275,[17,85,1276,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 u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1276,[1277]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1277,[17,780,1278,1307,1308,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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1278,[1279]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1279,[1280,1281,1304,1306]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1280,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1281,[1282,1283,1284,1285,1286,1287,1288,1289,1290,1293,1297,1294,1298]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1282,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1283,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1284,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1285,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1290,[1291]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1294,[1295,1296]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1295,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1296,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1299,[1294]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1300,[1294]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1302,[1294,1282]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1303,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1304,[1305]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1306,[1305]); +__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}});var t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1307,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1308,[17,780,1309,8]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1309,[]); +__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 u}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1310,[13,17,777,858,876,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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1311,[822,13,17,85,1275,777,851,858,804,1274,1255,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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1312,[822,13,17,85,1250,777,858,876,851,863,804,1251,1255,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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1313,[822,13,17,777,858,876,863,804,1274,1255,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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1314,[822,13,17,777,858,876,804,1274,1255,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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1315,[13,17,777,863,1140,1316,858,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},1316,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1317,[13,1055,17,385,85,777,863,858,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}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),r=_r(d[3]),o=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),k=_r(d[13]),j=_r(d[14]),x=_r(d[15]),p=_r(d[16]),f=_r(d[17]),v=_r(d[18]);function w(){const e=(0,b.useBasket)(),w=(0,b.useRestaurant)(e.restaurantId??void 0),C=(0,b.useAllMenu)(e.restaurantId??void 0),S=(0,b.useCustomer)(),T=(0,b.useOrders)(w?.id),B=(0,b.useStore)(e=>e.setLineQty),I=(0,b.useStore)(e=>e.overrideLine),O=(0,b.useStore)(e=>e.startBasket),P=(0,b.useNow)(15e3),[$,N]=(0,a.useState)(null),[M,F]=(0,a.useState)(!1),[L,R]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,o.startForm)()),[A,D]=(0,a.useState)(''),[E,Y]=(0,a.useState)(S.phone??''),[_,q]=(0,a.useState)(S.email??''),[H,G]=(0,a.useState)(!1),[V,K]=(0,a.useState)(S.name&&'Guest'!==S.name?S.name:''),[Q,U]=(0,a.useState)(!1),W=(0,b.useOrderAtTable)(e.restaurantId??void 0),J=(0,f.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{W||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[W,e.mode]);const[X,Z]=(0,a.useState)(null),[ee,le]=(0,a.useState)(!1),te=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,C,S.allergies),[e,C,S.allergies]);if(!w||!e.lines.length)return(0,v.jsxs)(i.Screen,{title:"Your basket",children:[(0,v.jsx)(i.Muted,{children:"Your basket is empty."}),(0,v.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ae=W&&'table'===e.mode,ne=(0,x.bookingRulesOf)(w),re=!ae&&(0,x.emailRequired)(ne,'takeaway-online'),oe=(0,h.takeawaySlots)(w,T,P),se=te.reduce((e,l)=>e+l.unitPrice*l.qty,0),ie=te.some(e=>e.contains.length&&!e.overridden),de=e.lines.filter(e=>{const l=C.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ae&&'on'!==(0,f.takeawayAvail)(l,J)}),ue=!ae&&!$,ce=!ae&&w.settings.takeawayPaused,he=(0,j.ukPhone)(E),me=V.trim().length>=2&&'guest'!==V.trim().toLowerCase(),ge=ae||(0,f.takesCardTakeaway)(w,p.IS_ISOLATED_VENUE),be=!Q&&ge&&!ie&&!de.length&&M&&!ue&&!ce&&(ae||me&&he.ok&&(0,j.emailOk)(_)&&(!re||!!_.trim())),ye=async()=>{U(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ae?void 0:$,tip:0,notes:L,phone:ae?void 0:he.pretty,email:ae?void 0:_.trim()||void 0,...ae?{}:(0,x.marketingChoice)(_,ne.marketingOptIn&&H),customerName:ae?void 0:V.trim()});(0,o.rememberGuard)(e.id,(0,o.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{U(!1)}},ke=e.lines.find(e=>e.key===X),je=ke?te[e.lines.indexOf(ke)]:void 0;return(0,v.jsxs)(i.Screen,{title:"Your basket",subtitle:`${w.name} \xb7 ${ae?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,v.jsxs)(s.default,{style:{gap:8},children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,v.jsx)(i.T,{weight:"bold",size:20,colour:k.colours.gold,children:(0,c.gbp)(se)})]}),ge?ie?(0,v.jsx)(i.T,{size:14,colour:k.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):M?ue&&!ce?(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Choose a collection time."}):ae||me?ae||he.ok?null:(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your mobile number."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Add your name for the order."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Confirm your allergies to continue."}):(0,v.jsx)(i.T,{size:14,colour:k.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ae?(0,v.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!be,onPress:()=>ye(),testID:"send-table-order"}):(0,v.jsx)(i.Button,{label:Q?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(se)}`,disabled:!be,onPress:()=>ye(),testID:"checkout"}),ae?null:(0,v.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ae||e.tableNo,null),ae?(0,v.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,w.fictional?null:(0,v.jsx)(i.AllergenNotice,{phone:w.phone}),te.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,v.jsxs)(i.Card,{highlight:l.contains.length?k.colours.red:l.may.length?k.colours.amber:void 0,children:[(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,v.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,v.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,v.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,v.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,v.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,v.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${S.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,v.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,v.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{le(!1),Z(a.key)}})]})]}):l.contains.length?(0,v.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,v.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,de.includes(a)?(0,v.jsx)(i.Badge,{kind:"amber",label:!ae&&J&&C.find(e=>e.id===a.itemId)&&'sold-out'===(0,f.takeawayAvail)(C.find(e=>e.id===a.itemId),J)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,v.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>B(a.key,0)}),(0,v.jsx)(i.Stepper,{value:a.qty,onChange:e=>B(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,v.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${w.id}`)}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(P)]}),ce?(0,v.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===oe.length?(0,v.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(i.Muted,{children:["15-minute slots, max ",w.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:oe.slice(0,16).map(e=>(0,v.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>N(e.time.toISOString())},e.label))})]})]}),(0,v.jsxs)(i.Card,{highlight:M?void 0:k.colours.amber,children:[(0,v.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,v.jsx)(i.Row,{wrap:!0,gap:6,children:S.allergies.length?S.allergies.map(e=>(0,v.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,v.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,v.jsx)(i.Toggle,{label:S.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:M,onChange:F}),(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ae?null:(0,v.jsxs)(i.Card,{children:[(0,v.jsx)(i.H2,{children:"Your details"}),(0,v.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:V,onChangeText:K,autoComplete:"name",placeholder:"e.g. Sam Smith"}),V&&!me?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:"Please add your name."}):null,(0,v.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:E,onChangeText:Y,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!he.ok&&E?(0,v.jsx)(i.T,{size:13,colour:k.colours.amber,children:he.error}):null,(0,v.jsx)(i.Field,{label:re?'Email (needed to order)':'Email (optional)',value:_,onChangeText:q,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,j.emailOk)(_)?null:(0,v.jsxs)(i.T,{size:13,colour:k.colours.amber,children:["That email doesn\u2019t look quite right.",re?'':' Check it, or leave it blank.']}),ne.marketingOptIn&&_.trim()?(0,v.jsx)(i.Toggle,{label:ne.marketingWords,value:H,onChange:G,testID:"basket-marketing"}):null,(0,v.jsx)(i.Muted,{children:"CoverCharge confirms by email. Your order confirmation and collection time are also shown here."})]}),(0,v.jsx)(i.Field,{label:"Order notes (optional)",value:L,onChangeText:R,placeholder:"e.g. cutlery please"}),ae?(0,v.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>O(w.id,'takeaway')}):null,(0,v.jsxs)(i.Sheet,{visible:!!ke,onClose:()=>Z(null),title:"Allergy override",children:[je?(0,v.jsx)(i.Banner,{kind:"danger",title:`${je.name} contains ${je.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,v.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:ee,onChange:le}),(0,v.jsx)(i.Button,{kind:"danger",disabled:!ee,label:"Confirm override",onPress:()=>{ke&&je&&I(ke.key,je.contains),Z(null)}})]}),(0,v.jsx)(r.Honeypot,{value:A,onChange:D})]})}},1318,[843,13,17,1239,917,85,777,845,851,1105,863,858,816,804,848,1079,805,900,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 e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1319,[13,17,85,1246,777,845,862,858,804,1271,805,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 n=r(d[0]);r(d[1]);var t=r(d[2]),u=r(d[3]);function c(){const{token:c}=(0,n.useLocalSearchParams)();return(0,u.jsx)(t.ManageScreen,{token:c})}},1320,[13,17,1321,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManageScreen=function({token:e}){const[t,l]=(0,n.useState)(null),[r,c]=(0,n.useState)({s:'loading'});(0,n.useEffect)(()=>{let n=!0;return(async()=>{const t=(0,d.tokenOk)(e)?await(0,o.loadView)(e):null;n&&(t&&t.ok?(l(t),c({s:'main'})):c({s:'stop',title:d.W.linkTitle,body:d.W.linkBody}))})(),()=>{n=!1}},[e]);const j=d.W.bookingTitle;if('loading'===r.s)return(0,h.jsx)(s.Screen,{title:d.W.bookingTitle,back:!1,children:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading})})});if('stop'===r.s||!t){const e='stop'===r.s?r:{title:d.W.linkTitle,body:d.W.linkBody};return(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:e.title}),(0,h.jsx)(s.T,{center:!0,children:e.body})]})})})}if('done'===r.s){const e=(0,d.doneWords)(r.kind,t,r.after);return(0,h.jsx)(s.Screen,{title:j,subtitle:t.venue.name,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-done-title",children:e.title}),e.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})})})}return'confirm'===r.s?(0,h.jsx)(k,{token:e,view:t,onBack:()=>c({s:'main'}),onDone:()=>c({s:'done',kind:'cancelled'}),onStop:(e,n)=>c({s:'stop',title:e,body:n})}):'booking'!==t.kind?(0,h.jsx)(s.Screen,{title:j,back:!1,children:(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-stop-title",children:d.W.linkTitle}),(0,h.jsx)(s.T,{center:!0,children:d.W.linkBody})]})})}):(0,h.jsx)(x,{token:e,view:t,onCancel:()=>c({s:'confirm'}),onDone:e=>c({s:'done',kind:'changed',after:e})})};var e,n=_r(_d[0]),t=_r(_d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[2]),r=_r(_d[3]),c=_r(_d[4]),d=_r(_d[5]),o=_r(_d[6]),h=_r(_d[7]);const u=({children:e,gap:n=8})=>(0,h.jsx)(l.default,{style:{alignItems:'center',gap:n,width:'100%'},children:e});function j({view:e}){const n=(0,d.callWords)(e.callReason,e);return n?(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-call-title",children:n.title}),(0,h.jsx)(s.T,{center:!0,testID:"manage-call-body",children:n.body})]})}):null}function x({token:e,view:t,onCancel:l,onDone:x}){const[k,y]=(0,n.useState)(t.party),[b,f]=(0,n.useState)(t.date),[p,W]=(0,n.useState)(t.time),[C,D]=(0,n.useState)(null),[S,v]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[w,B]=(0,n.useState)(null),M=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date),P=`${b}|${k}`,H=C?.key===P?C.list:null;(0,n.useEffect)(()=>{if(!t.canChange)return;let n=!0;return(0,o.loadTimes)(e,b,k).then(e=>{n&&D({key:`${b}|${k}`,list:e??[]})}),()=>{n=!1}},[e,b,k,t.canChange]);const $=(0,d.canSave)(t,{date:b,time:p,party:k,allergyOk:S}),_=async()=>{if(!p)return;T(!0),B(null);const n=await(0,o.changeBooking)(e,{date:b,time:p,party:k,children:Math.min(t.children,k-1),allergyOk:S});T(!1),n.ok?x({date:b,time:p,party:k,status:n.status}):B((0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,footer:t.canChange?(0,h.jsx)(s.Button,{testID:"manage-save",label:I?d.W.saving:$.ok?d.W.save:$.why??d.W.save,disabled:!$.ok||I,onPress:()=>{_()}}):void 0,children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.H2,{testID:"manage-summary",children:(0,d.bookingLine)(t.date,t.time,t.party)}),(0,h.jsx)(s.T,{center:!0,colour:c.colours.goldLight,children:(0,d.statusWords)(t.status)}),t.ref?(0,h.jsxs)(s.Muted,{center:!0,children:["Reference ",t.ref]}):null]})}),(0,h.jsx)(j,{view:t}),t.canChange?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{children:d.W.changeHeading}),(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.party}),(0,h.jsx)(r.PartySizeInput,{value:k,onChange:e=>{y(e),W(null)},min:t.rules.partyMin,max:t.rules.partyMax,label:"Party size",testID:"manage-party"}),(0,d.needsTeamCheck)(t.rules,k)?(0,h.jsx)(s.Muted,{center:!0,children:(0,d.teamCheckWords)(k)}):null]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.date}),(0,h.jsx)(s.T,{center:!0,size:18,testID:"manage-date",children:(0,d.longDate)(b)}),(0,h.jsxs)(s.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.earlier,disabled:b<=M,onPress:()=>{f((0,d.addDays)(b,-1)),W(null)},testID:"manage-day-earlier"}),(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:d.W.later,onPress:()=>{f((0,d.addDays)(b,1)),W(null)},testID:"manage-day-later"})]})]})}),(0,h.jsx)(s.Card,{children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:d.W.time}),null==H?(0,h.jsx)(s.Muted,{center:!0,children:d.W.loading.replace('your booking','times')}):0===H.length?(0,h.jsx)(s.Muted,{center:!0,children:d.W.closed}):H.some(e=>e.ok)?null:(0,h.jsx)(s.Muted,{center:!0,children:d.W.noTimes}),(0,h.jsx)(s.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(H??[]).map(e=>(0,h.jsx)(s.Chip,{testID:`manage-time-${e.time}`,label:e.time,sub:e.ok?e.drinksOnly?'Drinks only':void 0:'Full',disabled:!e.ok,selected:p===e.time,onPress:()=>W(e.time)},e.time))})]})}),t.rules.allergyConfirm?(0,h.jsx)(s.Card,{highlight:S?void 0:c.colours.amber,children:(0,h.jsxs)(u,{children:[(0,h.jsx)(s.Chip,{testID:"manage-allergy",label:`${S?'\u2713 ':''}${t.rules.allergyWords}`,selected:S,onPress:()=>v(!S)}),(0,h.jsx)(s.Muted,{center:!0,children:"Tap to confirm. If anything has changed about allergies, please call us before your visit."})]})}):null,w?(0,h.jsx)(s.Banner,{kind:"warn",title:"We couldn\u2019t change it",children:w}):null,(0,h.jsx)(u,{children:(0,h.jsx)(s.Button,{kind:"danger",label:d.W.cancelBooking,onPress:l,testID:"manage-cancel",style:{alignSelf:'center',minWidth:240}})})]}):null,(0,d.callWords)(t.callReason,t)?null:(0,h.jsx)(u,{children:(0,h.jsx)(s.Muted,{center:!0,testID:"manage-call-line",children:(0,d.callLine)(t.venue.phone,'booking',t.canChange)})})]})}function k({token:e,view:t,onBack:l,onDone:r,onStop:j}){const[x,k]=(0,n.useState)(!1),y=(0,d.confirmCancelWords)(t),b=async()=>{k(!0);const n=await(0,o.cancelByLink)(e,!0);k(!1),n.ok?r():j('We couldn\u2019t cancel it here',(0,d.refusalWords)(n,t))};return(0,h.jsxs)(s.Screen,{title:d.W.bookingTitle,subtitle:t.venue.name,back:!1,children:[(0,h.jsx)(s.Card,{highlight:c.colours.amber,children:(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.H2,{testID:"manage-confirm-title",children:y.title}),y.lines.map(e=>(0,h.jsx)(s.T,{center:!0,children:e},e))]})}),(0,h.jsxs)(u,{gap:10,children:[(0,h.jsx)(s.Button,{kind:"danger",label:x?'Cancelling\u2026':y.yes,disabled:x,onPress:()=>{b()},testID:"manage-confirm-yes",style:{alignSelf:'center',minWidth:260}}),(0,h.jsx)(s.Button,{kind:"secondary",label:y.no,onPress:l,testID:"manage-confirm-no",style:{alignSelf:'center',minWidth:260}})]})]})}},1321,[17,85,777,1099,804,1322,1323,8]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.longDate=o,Object.defineProperty(e,"people",{enumerable:!0,get:function(){return r}}),e.addDays=l,Object.defineProperty(e,"W",{enumerable:!0,get:function(){return c}}),e.callLine=s,e.callWords=u,Object.defineProperty(e,"bookingLine",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"statusWords",{enumerable:!0,get:function(){return y}}),e.needsTeamCheck=function(n,t){return t>n.autoAcceptUpTo},Object.defineProperty(e,"teamCheckWords",{enumerable:!0,get:function(){return m}}),e.canSave=function(n,t){return n.canChange?t.time?t.partyn.rules.partyMax?{ok:!1,why:`Online bookings are for ${n.rules.partyMin} to ${n.rules.partyMax} people. For more, please call us.`}:n.rules.allergyConfirm&&!t.allergyOk?{ok:!1,why:'Confirm the allergy information'}:t.date===n.date&&t.time===n.time&&t.party===n.party?{ok:!1,why:c.sameAsNow}:{ok:!0}:{ok:!1,why:c.pickTime}:{ok:!1}},e.refusalWords=function(n,t){if(n.message)return n.message;const o=u(n.reason??'call',t);return o?`${o.title}. ${o.body}`:c.tryAgain},e.doneWords=function(n,t,o){if('cancelled'===n)return{title:c.cancelledTitle,lines:[`${t.venue.name}: ${d(t.date,t.time,t.party)}.`,c.emailedCancel]};const r=d(o?.date??t.date,o?.time??t.time,o?.party??t.party);return{title:c.changedTitle,lines:[`${t.venue.name}: ${r}.`,'pending'===o?.status?c.pendingCheck:c.emailed,s(t.venue.phone,'booking')]}},e.confirmCancelWords=function(n){return{title:c.confirmCancelTitle,lines:[`${n.venue.name}: ${d(n.date,n.time,n.party)}.`,`Once it\u2019s cancelled, it can\u2019t be put back here. If you change your mind, ${s(n.venue.phone,'booking',!1).replace(/^Call/,'call')}`],yes:c.yesCancel,no:c.keep}},Object.defineProperty(e,"tokenOk",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PREVIEW_TOKEN",{enumerable:!0,get:function(){return p}}),e.previewView=function(n,t){const o={name:'The Anchorage',phone:'01292 502826',slug:'anchorage'};if(n===p)return{ok:!0,kind:'booking',venue:o,ref:'ANC-4821',date:l(t,3),time:'19:30',party:4,children:0,status:'confirmed',canChange:!0,canCancel:!0,callReason:null,rules:{partyMin:1,partyMax:12,autoAcceptUpTo:12,allergyConfirm:!0,allergyWords:'I have told the restaurant about any allergies in my party.',noticeMins:30}};return null},e.previewTimes=function(){const n=new Set(['18:30','19:00']);return['17:00','17:15','17:30','17:45','18:00','18:15','18:30','18:45','19:00','19:15','19:30','19:45','20:00','20:15','20:30'].map(t=>({time:t,ok:!n.has(t)}))};const n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],t=['January','February','March','April','May','June','July','August','September','October','November','December'];function o(o){const[r,l,c]=o.split('-').map(Number),s=new Date(Date.UTC(r,l-1,c,12));return`${n[s.getUTCDay()]} ${c} ${t[l-1]} ${r}`}const r=n=>`Table for ${n}`;function l(n,t){const[o,r,l]=n.split('-').map(Number);return new Date(Date.UTC(o,r-1,l+t,12)).toISOString().slice(0,10)}const c={changeButton:'Change or cancel your booking',bookingTitle:'Your booking',changeHeading:'Change your booking',party:'How many people?',date:'Date',time:'Time',earlier:'Earlier day',later:'Later day',noTimes:'There are no free times online that day. Please try another day or call us.',closed:'We\u2019re closed that day. Please try another day.',save:'Save changes',saving:'Saving\u2026',pickTime:'Choose a time',cancelBooking:'Cancel my booking',confirmCancelTitle:'Cancel your booking?',yesCancel:'Yes, cancel my booking',keep:'No, keep my booking',changedTitle:'Your booking has changed',cancelledTitle:'Your booking is cancelled',emailed:'We\u2019ve emailed you the new details.',emailedCancel:'We\u2019ve emailed you to confirm. We hope to see you another time.',pendingCheck:'The team will check it and confirm by email.',linkTitle:'This link has run out',linkBody:'Change and cancel links stop working at the booking time, or once a booking is cancelled. Please call the restaurant and quote your booking details.',sameAsNow:'That\u2019s the same as your booking now.',loading:'Loading your booking\u2026',tryAgain:'Something went wrong. Please try again, or call us.'};function s(n,t="booking",o=!0){const r=(n??'').trim();return r?`${o?'Or call':'Call'} us on ${r} and quote your ${t} details.`:`${o?'Or call':'Call'} the restaurant and quote your ${t} details.`}function u(n,t){const o=s(t.venue.phone,'booking',!1);switch(n){case null:return null;case'deposit':return{title:'Please call us about this booking',body:`This booking has a deposit, so we\u2019ll sort any change or cancellation with you on the phone. ${o}`};case'call':return{title:'Please call us to change this booking',body:o};case'started':return{title:'This booking can\u2019t be changed online now',body:o};case'cancelled':return{title:'This booking is cancelled',body:`Want to book again? ${o.replace(' and quote your booking details.','.')}`};case'link':return{title:c.linkTitle,body:c.linkBody}}}const d=(n,t,r)=>`${o(n)} at ${t}, table for ${r}`,y=n=>'pending'===n?'Waiting for the team to confirm':'confirmed'===n?'Confirmed':'cancelled'===n?'Cancelled':'Booked';const m=n=>`For ${n} people the team checks the booking first, then confirms by email.`;const h=n=>!!n&&/^[A-Za-z0-9_-]{43}$/.test(n),p='preview-booking-0000000000000000000000000000'.slice(0,43)},1322,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.loadView=async function(n){return r(n)?(0,o.previewView)(n,c())??{ok:!1,reason:'link'}:s('guest_link_view',{p_token:n})},e.loadTimes=async function(n,t,c){if(r(n))return(0,o.previewTimes)();const u=await s('guest_link_times',{p_token:n,p_date:t,p_party:c});return u.ok&&'times'in u?u.times:[]},e.changeBooking=async function(n,t){return r(n)?{ok:!0,status:'confirmed'}:s('guest_link_change_booking',{p_token:n,p_date:t.date,p_time:t.time,p_party:t.party,p_children:t.children,p_allergy_ok:t.allergyOk})},e.cancelByLink=async function(n,t){return r(n)?t?{ok:!0,status:'cancelled'}:{ok:!1,reason:'confirm'}:s('guest_link_cancel_booking',{p_token:n,p_confirm:t})};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]);const r=n=>!(0,t.isSupabaseConfigured)()&&n===o.PREVIEW_TOKEN,c=()=>new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/London',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date);async function s(o,r){if(!(0,t.isSupabaseConfigured)())return{ok:!1,reason:'link'};try{const{data:t,error:c}=await(0,n.getSupabase)().rpc(o,r);return c||!t?{ok:!1}:t}catch{return{ok:!1}}}},1323,[928,971,1322]); +__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 e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1324,[843,13,17,85,1248,777,845,851,863,858,804,1325,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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1325,[17,354,362,219,13,777,851,804,900,1326,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1326,[928,899]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1327,[843,1255,13,17,85,777,845,851,863,858,864,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]})}},1328,[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=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1329,[822,13,17,777,858,805,1255,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 u}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1330,[13,17,777,1331,1154,1255,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1331,[812,843,17,85,777,845,851,1154,1332,858,804,8]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1332,[928,899,1154]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1333,[13,17,856,1334,1406,8]); +__d(function(_g,_r,_i,_a,m,_e2,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Xe}}),_e2.DisplayBoard=function(e={}){const t=(0,ne.useOwner)(e=>e.site);return(0,se.useRestaurant)(t)?(0,Ye.jsx)(rt,{...e}):(0,Ye.jsx)(K.default,{testID:"display-venue-loading",style:{flex:1,backgroundColor:le.colours.bg,alignItems:'center',justifyContent:'center',padding:24},children:(0,Ye.jsx)(Q.Muted,{center:!0,children:"Loading your venue\u2026"})})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),i=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),I=_r(_d[20]),k=_r(_d[21]),D=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),R=_r(_d[27]),$=_r(_d[28]),B=_r(_d[29]),W=_r(_d[30]),L=_r(_d[31]),z=_r(_d[32]),H=_r(_d[33]),P=e(H),M=_r(_d[34]),A=_r(_d[35]),O=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),_=e(_r(_d[39])),G=e(_r(_d[40])),F=e(_r(_d[41])),V=e(_r(_d[42])),U=e(_r(_d[43])),K=e(_r(_d[44])),q=e(_r(_d[45])),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),le=_r(_d[54]),ie=_r(_d[55]),ne=_r(_d[56]),oe=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),xe=_r(_d[69]),me=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),Ie=_r(_d[73]),ke=_r(_d[74]),De=_r(_d[75]),ve=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),Re=_r(_d[80]),$e=_r(_d[81]),Be=_r(_d[82]),We=_r(_d[83]),Le=_r(_d[84]),ze=_r(_d[85]),He=_r(_d[86]),Pe=_r(_d[87]),Me=_r(_d[88]),Ae=_r(_d[89]),Oe=_r(_d[90]),Ee=_r(_d[91]),Ne=_r(_d[92]),_e=_r(_d[93]),Ge=_r(_d[94]),Fe=_r(_d[95]),Ve=_r(_d[96]),Ue=_r(_d[97]),Ke=_r(_d[98]),qe=_r(_d[99]),Ye=_r(_d[100]);const Qe='#221C12',Je='#2E2618',Xe=12e4,Ze={paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},et={flexDirection:'row',flexWrap:'nowrap',justifyContent:'center',alignItems:'center',gap:10,alignSelf:'stretch'},tt={width:k.IS_CAR?560:400,maxWidth:'100%',flexShrink:0},st=e=>(e??'').replace(' (example)',''),lt=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),it=e=>e.slotTime?(0,te.hm)(new Date(e.slotTime)):'ASAP';function nt({items:e,tight:t,phone:s,split:l,inline:i,splitOnly:n}){return(0,Ye.jsxs)(K.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:n?'center':'stretch',maxWidth:n?560:void 0,width:n?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[n?null:(0,Ye.jsx)(K.default,{style:{flexDirection:'row',flexWrap:s?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,l)=>{const i=(0,Ye.jsxs)(K.default,{testID:e.testID,style:{flex:s?1:void 0,minWidth:s?148:void 0,flexBasis:s?148:void 0,flexDirection:s?'column':'row',alignItems:s?'center':'baseline',justifyContent:s?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:l?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...s?{minHeight:76}:{}},children:[(0,Ye.jsx)(Q.T,{size:s?24:19,weight:"semibold",colour:e.alert?le.colours.amber:le.colours.text,children:e.value}),(0,Ye.jsx)(Q.T,{size:s?14:12,colour:le.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:s?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ye.jsx)(P.default.Fragment,{children:i},e.testID)})}),l?(0,Ye.jsx)(K.default,{testID:"covers-split",accessible:!0,accessibilityLabel:l.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||n?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:l.empty?(0,Ye.jsx)(Q.T,{size:14,colour:le.colours.muted,children:"No Covers yet"}):(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",colour:le.colours.gold,children:`Walk-ins ${l.walkIns} \xb7 ${l.walkInPct}%`}),(0,Ye.jsx)(Q.T,{size:i?13:14,weight:"semibold",children:`Bookings ${l.bookings} \xb7 ${l.bookingPct}%`})]}),(0,Ye.jsxs)(K.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:le.colours.gold},children:[(0,Ye.jsx)(K.default,{style:{width:`${l.walkInPct}%`,backgroundColor:le.colours.gold}}),(0,Ye.jsx)(K.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function ot({chipId:e,label:t,sub:s,selected:l,onPress:i,colour:n,compact:o}){return(0,Ye.jsxs)(V.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:l},accessibilityLabel:`${t}${s?`, ${s}`:''}${l?', selected':''}`,'aria-pressed':l,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:o?4:7,minHeight:44,paddingHorizontal:o?6:14,borderRadius:999,borderWidth:1,borderColor:l?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:l?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[n?(0,Ye.jsx)(K.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:n}}):null,(0,Ye.jsx)(Q.T,{size:o?12:14,weight:l?'semibold':'medium',colour:l?le.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),s?(0,Ye.jsx)(Q.T,{size:12,colour:le.colours.muted,children:s}):null]})}function at({list:e,me:t,compact:s,bookings:l}){const i=(e,t)=>(0,Ue.statusBlock)(e,t,(0,Ue.linkedBooking)(e,l));return e.length?(0,Ye.jsx)(K.default,{style:{gap:8},children:e.map(e=>(0,Ye.jsxs)(K.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:le.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?le.colours.ok:e.allergies.length?le.colours.red:le.colours.gold},children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:s?16:18,weight:"bold",children:[it(e)," \xb7 ",st(e.customerName)]}),(0,Ye.jsx)(Q.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ye.jsxs)(Q.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,ee.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ye.jsx)(Ve.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ye.jsxs)(Q.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ye.jsx)(Q.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>se.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ye.jsx)(Q.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ye.jsx)(Q.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>se.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ye.jsx)(Te.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ye.jsx)(Q.Muted,{children:"No takeaway orders right now."})}function rt({embedded:e=!1,boardW:b,headerExtra:ee,subHeader:Ve,noVoice:Ue=!1}={}){const it=(0,q.default)(),rt=b??it.width,ct=it.height,ut=rt<700,ht=rt>=ct,gt=!ut&&ht&&rt>=600,bt=gt,yt=Math.round(Math.min(520,Math.max(rt>=1e3?448:280,.3*rt))),pt=P.default.useRef(null),ft=P.default.useRef(0),[xt,mt]=(0,H.useState)({w:0,h:0}),jt=(0,ne.useOwner)(e=>e.site),wt=(0,se.useRestaurant)(jt);(0,$e.useAlertWatcher)(jt,{enabled:!e});const It=(0,se.useOrders)(jt),kt=(0,se.useBookings)(jt),Dt=(0,se.useEvents)(jt),vt=(0,se.useStore)(e=>e.skipMinutes),St=(0,se.useStore)(e=>e.clock.mode),Ct=(0,se.useNow)(5e3),Tt=(0,ne.useOwner)(e=>e.staff),Rt=(0,ne.useOwner)(e=>e.attendance),$t=(0,ne.useOwner)(e=>e.shifts),Bt=(0,ne.useOwner)(e=>e.leave),Wt=P.default.useMemo(()=>(0,Ne.workingShifts)($t,Bt),[$t,Bt]);P.default.useEffect(()=>{(0,ae.ensureAttendance)((0,te.ymd)(Ct),Ct)},[(0,te.ymd)(Ct)]);const Lt=(0,R.useSession)(e=>e.meId),zt=(0,D.displayActionBy)({isCar:k.IS_CAR,isDisplayApp:'display'===k.APP_VARIANT&&!e,personName:st(Tt.find(e=>e.id===Lt)?.name)}),Ht=k.IS_CAR?'Car':'Display';(0,W.useSoldOutLink)(!1,e?void 0:Ht,!0);const Pt=(0,te.ymd)(Ct),Mt=(0,A.useTravelDay)('display',Pt),At=(0,oe.useFrontDoor)(Pt,ht),Ot=(0,re.useDisplaySettings)(jt),Et=Ot.privacy,Nt=(0,fe.useSaverSync)(),_t=(0,re.usePlan)(jt),Gt=(0,re.useFloor)(e=>e.live[jt]),Ft=(0,Be.useBlocks)(e=>e.blocks),[Vt,Ut]=(0,H.useState)('plan'),[Kt,qt]=(0,H.useState)(!1),[Yt,Qt]=(0,H.useState)('all'),[Jt,Xt]=(0,H.useState)(null),[Zt,es]=(0,H.useState)(null),[ts,ss]=(0,H.useState)(null),[ls,is]=(0,H.useState)(!1),[ns,os]=(0,H.useState)(!1),[as,rs]=(0,H.useState)(null),[ds,cs]=(0,H.useState)(!1),[us,hs]=(0,H.useState)(!1),[gs,bs]=(0,H.useState)(!1),[ys,ps]=(0,H.useState)(!1),[fs,xs]=(0,H.useState)(null),[ms,js]=(0,H.useState)(null),[ws,Is]=(0,H.useState)(null),[ks,Ds]=(0,H.useState)(!1),vs=P.default.useRef(0),Ss=e=>{vs.current=Date.now(),Is(e)};P.default.useEffect(()=>{if(!ws)return;const e=setInterval(()=>{Date.now()-vs.current>=He.DAY_IDLE_MS&&Is(null)},5e3);return()=>clearInterval(e)},[ws]);const Cs=(0,se.useWaitlist)(jt),Ts=(0,se.useStore)(e=>e.walkIns[jt]??0),[Rs,$s]=(0,H.useState)(!1),[Bs,Ws]=(0,H.useState)(!1),[Ls,zs]=(0,H.useState)(!1),[Hs,Ps]=(0,H.useState)(!1);(0,X.useReviewAlerts)(jt);const[Ms,As]=(0,H.useState)({view:0,content:0}),[Os,Es]=(0,H.useState)(null);P.default.useEffect(()=>{Os&&((0,L.notify)({id:`floor-note:${Date.now()}`,title:Os,timeoutMs:4500,big:!0,testID:'floor-toast'}),Es(null))},[Os]),P.default.useEffect(()=>{if(!e)return(0,O.setDisplaySilent)(!0),()=>(0,O.setDisplaySilent)(!1)},[e]);const[Ns,_s]=(0,H.useState)(null),Gs=P.default.useRef(0),[Fs,Vs]=(0,H.useState)(null);P.default.useEffect(()=>{if(!Ns)return;Gs.current=Date.now();const e=setInterval(()=>{const e=Date.now()-Gs.current;if(e>=Xe)return _s(null),void Es('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Vs(e>=105e3?Math.ceil((Xe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[Ns]);const Us=e=>e.date!==Pt?ss({title:`Guest details \xb7 ${(0,He.dayWord)(e.date,Pt)} ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[!e.walkIn&&e.date>Pt?(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,He.dayWord)(e.date,Pt)}, ${e.time}`,disabled:!Ii.ok,accessibilityHint:Ii.hint,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}):null,(0,Se.bookingDetails)(e)]})}):ss({title:`Guest details \xb7 ${e.time}`,body:(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(dt,{rid:jt,id:e.id,turnBase:wt.settings.turnMins}),e.walkIn?null:(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{ss(null),rs(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ye.jsx)(Ie.CancelWalkInButton,{rid:jt,b:e,big:!0,onDone:e=>{ss(null),Es(e)}}):null,e.walkIn?(0,Ye.jsx)(Ie.ReinstateWalkInButton,{rid:jt,b:e,today:Pt,onDone:e=>{ss(null),Es(e)}}):null,(0,Se.bookingDetails)(e)]})}),Ks=kt.filter(e=>e.date===Pt).sort((e,t)=>e.time.localeCompare(t.time)),qs=Ks.filter(e=>!['cancelled','noshow'].includes(e.status)),Ys=It.filter(lt).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Qs=(0,H.useMemo)(()=>(0,c.forecastToday)(wt,kt,It,Dt,Ct),[wt,kt,It,Dt,Ct.getTime()/6e4|0]),Js=(0,Be.closedAreasAt)(Ft,jt,Pt,(0,te.hm)(Ct)),Xs=[...Js].join(','),Zs=(0,H.useMemo)(()=>(0,de.floorView)(_t,kt,It,Gt??{},Ct,wt.settings.turnMins,Js),[_t,kt,It,Gt,Ct.getTime(),Xs]),el=(0,ve.hoursFor)(wt,Ct),tl=el?.open??new Date(`${Pt}T12:00:00`),sl=el?.close??new Date(`${Pt}T21:00:00`),ll=(0,te.addMins)(tl,-tl.getMinutes()),il=(0,te.addMins)(sl,30),nl=e=>new Date(`${Pt}T${e}:00`),ol=(0,Be.blocksOn)(Ft,jt,Pt).map(e=>({from:nl(e.from),to:nl(e.to),label:e.reason??'Paused'})).concat((0,n.queuedServicePauses)(wt,Ct,Pt)),al=Object.keys(Zs).filter(e=>'blocked'===Zs[e]?.status),rl=ws&&ws!==Pt?ws:Pt,dl=rl!==Pt,cl=(0,He.dayWord)(rl,Pt),ul=/^(Today|Yesterday|Tomorrow)$/.test(cl),hl=dl?(0,He.bookingsForDay)(kt,rl,Pt).sort((e,t)=>e.time.localeCompare(t.time)):Ks,gl=(0,te.parseYmd)(rl);gl.setHours(12);const bl=dl?(0,ve.hoursFor)(wt,gl):el,yl=bl?.open??new Date(`${rl}T12:00:00`),pl=bl?.close??new Date(`${rl}T21:00:00`),fl=e=>new Date(`${rl}T${e}:00`),xl=[...dl?(0,Be.blocksOn)(Ft,jt,rl).map(e=>({from:fl(e.from),to:fl(e.to),label:e.reason??'Paused'})):ol,...dl?(0,n.queuedServicePauses)(wt,gl,rl):[]],ml=(0,n.queuedServiceSessions)(wt,gl),jl=l.IS_QUEUED_VENUE&&(void 0===ml||!ml.length),wl=(0,Ye.jsxs)(K.default,{testID:"queued-hours-gate",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:void 0===ml?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ye.jsx)(Q.Muted,{children:i.queuedVenues[jt]?.hours.note})]}),Il=dl?bl||hl.length?rldl?(0,de.dayFloorView)(_t,hl,rl):Zs,[dl,_t,hl,rl,Zs]),[Dl,vl]=(0,H.useState)(null),[Sl,Cl]=(0,H.useState)(null),[Tl,Rl]=(0,H.useState)(!1),[$l,Bl]=(0,H.useState)(null),Wl=dl?hl.filter(e=>!['cancelled','noshow'].includes(e.status)):qs,Ll=Wl.reduce((e,t)=>e+t.partySize,0),zl=(0,u.coversSplit)(Wl,rl),Hl=(0,Me.cancelledDayTally)(kt,rl),Pl=(0,Ae.cancellationsFor)(kt,rl,e=>e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)','')),Ml=(0,Me.cancelledTallyWords)(Hl,ul?cl.toLowerCase():dl?`on ${cl}`:'today'),Al=Ft.filter(e=>e.rid===jt&&e.date===rl&&!e.removedAt),Ol=60*yl.getHours()+yl.getMinutes(),El=60*pl.getHours()+pl.getMinutes(),Nl=(0,ze.chartBands)(Al,Ol,El),_l=(0,ze.seasonClosedAreaIds)(Al,Ol,El),Gl=_l.size?{..._t,areas:_t.areas.filter(e=>!_l.has(e.id)),tables:_t.tables.filter(e=>!_l.has(e.areaId))}:_t,Fl=dl?[]:al.filter(e=>!_l.has(_t.tables.find(t=>t.name===e)?.areaId??'')),Vl=new Set((0,ze.blockedHours)(Nl)),Ul=Ct.getHours()+(Ct.getMinutes()>=30?1:0),Kl=Qs.hours.filter(e=>e.hour>=Ul&&!Vl.has(e.hour)),ql=Kl.reduce((e,t)=>e+t.coversHigh,0),Yl=Kl.reduce((e,t)=>e+t.coversLow,0),Ql=Math.round((Yl+ql)/2),Jl=!Qs.example&&Qs.open&&Qs.enough&&ql>0?`Usually ${(0,c.coversRange)(Ql,Ql)} more`:void 0,Xl=async(e,t)=>{const s=Zs[e]?.booking;if(!s||e===t)return;const l=Zs[t]?.status;if(l&&!['free','soon'].includes(l))return void Es('dirty'===l?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${de.STATUS[l].label.toLowerCase()}. Pick a free table.`);if(!(0,ke.guardBookingChange)(Es,{b:s,tables:[t]}))return;await se.repo.bookings.update(s.id,{table:t});const i=Gt?.[e]?.stage;re.useFloor.getState().setLive(jt,t,{stage:i??'seated',dirty:!1}),re.useFloor.getState().setLive(jt,e,{stage:void 0,dirty:!0}),Es(`Saving: ${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,ke.reportBookingSave)(s.id,`${(0,xe.privName)(s,Et)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,xe.privName)(s,Et)} to ${(0,d.tableNumbers)(t)}`,Es)},Zl=e=>{if(ms)return Cl(null),void js(t=>t?{...t,tables:(0,De.toggleTable)(t.tables,e)}:t);dl?vl(e):Zt?(e!==Zt&&Xl(Zt,e),es(null)):Xt(e)},ei=ms?kt.find(e=>e.id===ms.id):void 0,ti=ms&&ei?(()=>{const e=ei.walkIn?(0,xe.privName)(ei,Et):st(ei.name),t=(0,De.seatsOf)(_t,ms.tables).total,s=(0,De.seatLine)(t,ei.partySize),l=(0,De.pickClashes)(ei,ms.tables,kt.filter(e=>e.date===ei.date),wt.settings.turnMins),i=(0,De.tableKey)(ms.tables)!==(0,De.tableKey)((0,re.tablesOf)(ei.table));return(0,Ye.jsxs)(K.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:le.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,padding:10},children:[(0,Ye.jsxs)(K.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,He.dayWord)(ei.date,Pt)} ${ei.time}. Tap tables on the plan to add or take them off. ${(0,De.tablesWords)(ms.tables)}. ${s.text}.${l.length?` ${l.length} clash${1===l.length?'':'es'} with other bookings.`:''}`,children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",colour:le.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,He.dayWord)(ei.date,Pt)," ",ei.time]}),(0,Ye.jsxs)(Q.T,{size:16,colour:le.colours.text,children:[(0,De.tablesWords)(ms.tables)," \xb7 ",s.text,l.length?` \xb7 ${[...new Set(l.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),Sl?(0,Ye.jsx)(K.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:Sl,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:Sl})}):null,Tl&&ei&&ms.tables.length?(0,Ye.jsx)(C.RestoreSeatedConfirm,{prompt:(0,T.restoreSeatedPrompt)(e,ms.tables.join('+')),onYes:()=>{Rl(!1),(async()=>{if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,s,e,t,Es)})()},onNo:()=>Rl(!1)}):null,(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:Sl?'plan-pick-overcap-yes':'plan-pick-save',label:Sl?'Use it anyway':l.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${Sl?'Use it anyway':l.length?'Save anyway':'Save'}, ${(0,De.tablesWords)(ms.tables)} for ${e}. ${s.text}.`,onPress:async()=>{if(!ei)return void js(null);if(!(0,ke.guardBookingChange)(Es,{b:ei,tables:ms.tables}))return Cl(null),void js(null);const s=(0,De.overCapacityAsk)(ms.tables,t,ei.partySize);if(s&&!Sl)return void Cl(s);if('finished'===ei.status&&ms.tables.length&&!Tl)return void Rl(!0);Cl(null),Rl(!1);const l=ms.tables;js(null),await(0,ke.saveTablesReported)(jt,ei,l,e,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{Cl(null),js(null)}})]})]})})():null,si=Gl.areas.filter(e=>Gl.tables.some(t=>t.areaId===e.id)),li=e=>{const t=_t.tables.filter(t=>t.areaId===e);return dl?`${t.filter(e=>!kl[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Zs[e.name]?.status??'free')).length}/${t.length} free`},ii='all'===Yt||si.some(e=>e.id===Yt)?Yt:'all',ni=e=>(0,Ye.jsx)(ce.FloorCanvas,{plan:Gl,areaId:e,mode:"live",fit:"contain",crop:!0,fill:gt,big:!0,view:kl,privacy:Et,turnBase:wt.settings.turnMins,highlight:ms?ms.tables:Zt?[Zt]:void 0,onTap:e=>Zl(e.name),onDrop:(e,t)=>ms||dl?void 0:Xl(e.name,t.name)}),oi=ut?1:ht||si.length>2?2:1,ai=e=>{const t=_t.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const s=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/s},ri=[];for(let e=0;e{const t=(0,ce.areaBounds)(_t,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,ce.minReadableScale)(_t,e.id)}}),xt.w,xt.h):null,ci=e=>(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',height:ue.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:li(e.id)})]}),ui=(0,Ye.jsx)(K.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:s}=e.nativeEvent.layout;(Math.abs(t-xt.w)>1||Math.abs(s-xt.h)>1)&&mt({w:t,h:s})},children:di?(0,Ye.jsx)(U.default,{style:{flex:1},scrollEnabled:di.scroll,showsVerticalScrollIndicator:di.scroll,contentContainerStyle:{gap:ue.GRID_GAP},children:di.rows.map((e,t)=>(0,Ye.jsx)(K.default,{style:{height:di.rowHeights[t],flexDirection:'row',gap:ue.GRID_GAP},children:e.map(e=>{const t=si.find(t=>t.id===e);return(0,Ye.jsxs)(K.default,{testID:`area-cell-${e}`,style:{width:di.cellW,gap:2},children:[ci(t),(0,Ye.jsx)(K.default,{style:{flex:1},children:ni(e)})]},e)})},t))}):null}),hi=(0,Ye.jsxs)(K.default,{testID:"venue-plan",style:{flex:ut?void 0:1,gap:10,minWidth:0},children:[(0,Ye.jsx)(r.TableNumberWarning,{plan:_t}),_t.tables.length?null:(0,Ye.jsxs)(K.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ye.jsx)(Q.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ye.jsx)(Q.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),l.IS_WILDINGS||l.IS_KIRKMICHAEL||l.IS_SOUTERS?(0,Ye.jsx)(Q.Muted,{center:!0,testID:"display-venue-hours",children:(l.IS_WILDINGS?a.WILDINGS_GUIDE:l.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ye.jsx)(ot,{chipId:"all",compact:!ut,label:"Whole venue",selected:'all'===ii,onPress:()=>Qt('all')},"__all"),...si.map(e=>(0,Ye.jsx)(ot,{chipId:e.id,compact:!ut,label:`${e.name}${(0,he.areaMarks)(e)}`,colour:(0,le.brandColour)(e.colour),sub:ut?Js.has(e.id)?'closed':ii===e.id?li(e.id):void 0:void 0,selected:ii===e.id,onPress:()=>Qt(e.id)},e.id))];return ut?(0,Ye.jsx)(K.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ye.jsx)(U.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;As(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>As(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:Ms.view>0&&Ms.content>0&&Ms.content<=Ms.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:Ms.view>0&&Ms.content<=Ms.view+1?'100%':void 0},children:e})})(),(0,Ye.jsx)(g.FloorLegend,{}),ti,Zt?(0,Ye.jsxs)(Q.Row,{gap:8,style:{backgroundColor:le.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ye.jsxs)(Q.T,{weight:"semibold",colour:le.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(Zt),": tap the new table."]}),(0,Ye.jsx)(Q.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>es(null)})]}):null,'all'===ii&>?ui:'all'===ii?(0,Ye.jsx)(K.default,{style:{flex:ut?void 0:1,gap:12,minHeight:bt?void 0:360},children:ri.map((e,t)=>(0,Ye.jsxs)(K.default,{style:{flex:ut?void 0:Math.max(.3,...e.map(e=>ai(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ye.jsxs)(K.default,{style:{flex:1,gap:2},children:[ut?(0,Ye.jsxs)(K.default,{style:{alignItems:'center',gap:4},children:[(0,Ye.jsxs)(Q.T,{center:!0,size:18,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{center:!0,size:14,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{center:!0,children:li(e.id)})]}):(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between'},children:[(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:(0,le.brandColour)(e.colour),children:[e.name,(0,he.areaMarks)(e)]}),Js.has(e.id)?(0,Ye.jsx)(Q.T,{size:13,weight:"semibold",colour:le.colours.blue,children:"Closed for weather"}):(0,Ye.jsx)(Q.Muted,{children:li(e.id)})]}),(0,Ye.jsx)(K.default,{style:ut?{height:Math.max(280,Math.round((rt-40)*ai(e.id)))}:{flex:1},children:ni(e.id)})]},e.id)),e.length{if(dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},rl)}),bi='timeline'===Vt,yi=Kt?(0,Ye.jsx)(G.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>qt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ye.jsxs)(K.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:le.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ye.jsx)(V.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>qt(!1),style:{minHeight:64,minWidth:rt<600?120:180,paddingHorizontal:rt<600?14:22,borderRadius:16,borderWidth:2,borderColor:le.colours.goldLight,backgroundColor:le.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ye.jsx)(K.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ye.jsx)(Q.T,{size:22,weight:"semibold",colour:le.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${dl?(0,He.dayLong)(rl):'Today'}`})}),rt<600?null:(0,Ye.jsx)(K.default,{style:{minWidth:180}})]}),jl?wl:(0,Ye.jsx)(K.default,{style:{flex:1,minHeight:0},children:(0,Ye.jsx)(ye.Timeline,{isToday:!dl,fit:!0,plan:Gl,bookings:dl?hl:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,t0:dl?(0,te.addMins)(yl,-yl.getMinutes()):ll,t1:dl?(0,te.addMins)(pl,30):il,pauses:dl?xl:ol,blockedTables:Fl,onOpen:e=>{if(qt(!1),dl)return void xs(e.id);const t=(0,re.tablesOf)(e.table)[0];t&&Zs[t]?Xt(t):Us(e)}},`full-${rl}`)})]})}):null,pi=dl?(0,Ye.jsxs)(K.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:le.colours.gold,backgroundColor:le.colours.goldTint},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:ul?`Showing ${cl} \xb7 ${(0,te.niceDate)((0,te.parseYmd)(rl))}`:`Showing ${(0,He.dayWord)(rl,Pt)}`}),(0,Ye.jsx)(K.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${Ml}. Showing ${(0,He.dayLong)(rl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ye.jsx)(Q.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{js(null),Ss(null)},style:{minHeight:44}})]}):null,fi=(0,Ye.jsx)(K.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:ut?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,s])=>{const i='timeline'===e===(bi||Kt);return(0,Ye.jsx)(V.default,{testID:s,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ut('plan'),qt(!0)):(qt(!1),Ut('plan'))},style:{flex:ut?1:void 0,minHeight:ut?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?le.colours.gold:'transparent',..._e.look.web(i?{backgroundImage:l.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:l.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ye.jsx)(Q.T,{size:ut?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),xi='display'===k.APP_VARIANT&&!e,mi='display'===k.APP_VARIANT&&!e,ji=!e&&!k.IS_CAR&&!ut,wi=xi?(0,Ye.jsxs)(K.default,{testID:"display-view-row",style:{flexDirection:ut?'column':'row',flexWrap:ut||ji?'nowrap':'wrap',gap:6,alignItems:ut||ji?'stretch':'center'},children:[fi,(0,Ye.jsx)(I.DisplayRotaKitchenButtons,{phone:ut,fill:ji,shifts:$t,staff:Tt,today:Pt,leave:Bt})]}):fi,Ii=(0,h.useBookingWrite)(),ki=e=>(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Walk-in",onPress:At.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"New booking",onPress:At.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint}),(0,Ye.jsx)(Ge.BigAction,{premium:!0,label:"Edit booking",onPress:()=>os(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ii.ok,accessibilityHint:Ii.hint})]});(0,qe.useDisplayNotices)(jt,!e);const Di=!e&&!k.IS_CAR&&!ut,vi=ut?180:202,[Si,Ci]=(0,H.useState)(ut?180:168),Ti=P.default.useRef(ut?180:168),Ri=P.default.useRef(null),$i=P.default.useRef(null),Bi=P.default.useRef(null),Wi=P.default.useRef(!1),[Li,zi]=(0,H.useState)(!1),Hi=!ut&&ct<=800,Pi=Le.DAY_GRAPH_CHROME+(Hi?24:8),Mi=P.default.useRef(0),[Ai,Oi]=(0,H.useState)(Pi),[Ei,Ni]=(0,H.useState)(!0),Gi=`${it.width}x${ct}`,[Fi,Vi]=(0,H.useState)(null),Ui=Fi===Gi,Ki=P.default.useRef(null),qi=P.default.useRef(0),Yi=P.default.useRef(()=>{}),Qi=P.default.useCallback(e=>{Math.abs(e-Mi.current)>=2&&(Mi.current=e,setTimeout(()=>Yi.current(),0))},[]),Ji=()=>{const e=Ri.current,t=$i.current;if(!e?.measureInWindow||!t?.measureInWindow)return;const s=(e,t,s,l,i=0)=>{const n=_.default.get('window');if(t<=0||s<=e)return;if((s>n.height+2||n.width!==it.width||n.height!==ct)&&qi.current<5)return qi.current+=1,void setTimeout(()=>Yi.current(),450);qi.current=0;const o=t>Ti.current?Math.ceil(t-Ti.current):0,a=Di?Math.max(Pi,Mi.current):Math.max(Pi,o);Di&&a!==Ai&&Oi(a);const r=!ut&&ct>=700?140:70,d=Math.floor(s-4-e)-a-l,c=i>0&&d-i>=r;if(Di&&c!==Ei&&Ni(c),Di&&!Ui)if(d<48){const e=Ki.current,t=Date.now();e&&e.key===Gi&&t-e.at>=300?(Ki.current=null,Vi(Gi)):(e&&e.key===Gi||(Ki.current={key:Gi,at:t}),setTimeout(()=>Yi.current(),450))}else Ki.current=null;const u=d-(c?i:0),h=Math.min(vi,u>=r?Math.max(r,u):Math.max(0,u));Math.abs(Ti.current-h)>=2&&(Ti.current=h,Ci(h))},l=44+(ct<820?4:8),i=46+(ct<820?4:8);e.measureInWindow((e,n,o,a)=>{t.measureInWindow((e,t)=>{const o=Bi.current;Di&&o?.measureInWindow?o.measureInWindow((e,l,o,r)=>{const d=ct<820?4:8;s(n,a,t,Math.max(i,d+Math.round(r||0)),Wi.current?44+d:0)}):s(n,a,t,Di?i:l)})})};Yi.current=Ji,P.default.useEffect(()=>{const e=setTimeout(()=>Yi.current(),60),t=setTimeout(()=>Yi.current(),450);return()=>{clearTimeout(e),clearTimeout(t)}},[rt,ct,rl]);const Xi=(0,Ye.jsxs)(K.default,{ref:$i,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),Ji()},style:{flexDirection:'row',flexWrap:rt>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:ut?12:Hi?2:6,justifyContent:ut?'center':void 0,borderTopWidth:1,borderTopColor:le.colours.hairline,backgroundColor:(0,o.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ye.jsx)(Ke.DisplayClockButton,{}),(0,Ye.jsx)(be.HoldToEdit,{quiet:!0,onUnlock:()=>{Vs(null),_s({at:Date.now()})},onHint:()=>Es('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ye.jsx)(We.BlockBookingsButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,display:!0,day:rl}),_t.areas.some(e=>e.outdoor)?(0,Ye.jsx)(We.CloseGardenButton,{rid:jt,r:wt,now:Ct,by:zt,quiet:!0,short:!0}):null,(0,Ye.jsx)(V.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ps(!0),style:({pressed:e})=>({..._e.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",colour:le.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ye.jsx)(f.GiftQrButton,{rid:jt,venue:wt.name})]}),Zi=Ys.length?(0,Ye.jsxs)(K.default,{testID:"takeaway-panel",style:[_e.look.panel,{overflow:'hidden'}],children:[(0,Ye.jsxs)(Q.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ye.jsx)(Q.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ye.jsxs)(Q.T,{size:12,colour:le.colours.muted,children:[Ys.length," live"]})]}),(0,Ye.jsx)(K.default,{style:{padding:10},children:(0,Ye.jsx)(at,{list:Ys,me:zt,compact:!0,bookings:kt})})]}):null,en=(Ee.DueToday,wt.settings.turnMins||90),tn=dl?hl:(0,v.todaysGuestList)(Ks,Ct,en),sn=dl?[]:(0,v.todaysFinishedList)(Ks,Ct,en),ln=dl?ul?`${cl}\u2019s guests`:`Guests ${cl}`:'Today\u2019s guests',nn=(0,Ye.jsxs)(Ye.Fragment,{children:[0===tn.length?(0,Ye.jsx)(Q.Muted,{children:dl?rl{const t=(0,v.isLeftEarly)(e,Ct,en),s=(0,ie.isSeatedHighlight)(e.status,{otherDay:dl})&&!t,l=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),seated:s,leftEarly:t,tableWord:!0}),i=le.colours.text,n=s?le.colours.goldLight:le.colours.muted,o=le.colours.gold,a=l.depositWarn?le.colours.amber:le.colours.goldLight;return(0,Ye.jsxs)(V.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:dl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>s?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,ie.seatedHighlightStyle)({backgroundColor:e?Je:Qe,borderColor:le.colours.gold,borderLeftColor:le.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ye.jsx)(Q.T,{size:18,weight:"semibold",colour:i,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ye.jsx)(K.default,{style:{paddingTop:2},children:(0,Ye.jsx)(N.AllergyIcon,{text:l.allergy,size:22,colour:le.colours.amber,ink:le.colours.bg,testID:`display-allergy-${e.id}`})}):null,'VIP'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-vip-${e.id}`,size:18,accessibilityLabel:"VIP",children:"\u2605"}):null,'Regular'===l.vip?(0,Ye.jsx)(Q.T,{testID:`display-regular-${e.id}`,size:18,accessibilityLabel:"regular",children:"\u2665"}):null,l.occasion&&de.OCCASION_ICON[l.occasion]?(0,Ye.jsx)(Q.T,{testID:`display-occasion-${e.id}`,size:18,accessibilityLabel:l.occasion,children:de.OCCASION_ICON[l.occasion]}):null]}),(0,Ye.jsxs)(Q.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ye.jsx)(Q.T,{size:16,colour:i,children:l.people}),l.deposit?(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}):null,l.deposit?(0,Ye.jsx)(Q.T,{size:16,weight:"semibold",colour:a,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ye.jsx)(Q.T,{size:16,colour:n,children:" \xb7 "}),(0,Ye.jsx)(Q.T,{size:16,weight:s?'semibold':'regular',colour:'No table yet'===l.table?n:i,children:l.table}),l.dog?(0,Ye.jsx)(Q.T,{size:16,children:" "}):null,l.dog?(0,Ye.jsx)(K.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ye.jsx)(je.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]}),l.guestChange?(0,Ye.jsx)(Q.T,{size:15,colour:le.colours.amber,testID:`display-guest-change-${e.id}`,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:l.guestChange}):null]},e.id)}),sn.length?(0,Ye.jsxs)(K.default,{testID:"display-finished-section",style:{marginTop:14,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,padding:8,gap:4},children:[(0,Ye.jsxs)(V.default,{testID:"display-finished-toggle",accessibilityRole:"button",accessibilityLabel:`Finished, ${sn.length}${ys?', expanded':', collapsed'}`,accessibilityState:{expanded:ys},onPress:()=>ps(e=>!e),style:({pressed:e})=>({minHeight:48,paddingHorizontal:8,paddingVertical:6,borderRadius:8,flexDirection:'row',alignItems:'center',justifyContent:'space-between',backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(Q.T,{size:16,weight:"semibold",colour:le.colours.goldLight,children:["Finished (",sn.length,")"]}),(0,Ye.jsx)(Q.T,{size:16,colour:le.colours.muted,children:ys?'\u25be':'\u25b8'})]}),ys?sn.map(e=>{const t=(0,me.guestRowText)(e,{name:e.walkIn?(0,xe.privName)(e,Et):(e.name??'').replace(' (example)',''),finished:!0,tableWord:!0});return(0,Ye.jsxs)(V.default,{testID:`display-finished-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:t.a11y,accessibilityHint:"Opens the booking",onPress:()=>{bs(!1),xs(e.id)},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:le.colours.hairline,backgroundColor:e?le.colours.tilePressed:'transparent'}),children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",colour:le.colours.gold,style:{width:58},children:t.time}),(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:t.name})]}),(0,Ye.jsxs)(Q.T,{size:15,colour:le.colours.muted,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[t.people," \xb7 ",t.table]}),(0,Ye.jsx)(K.default,{style:{marginLeft:68,marginTop:4,alignItems:'flex-start'},children:(0,Ye.jsx)(S.BookingUndo,{b:e,rid:jt,today:Pt,who:t.name,allowed:Ii.ok})})]},e.id)}):null]}):null,(0,Ye.jsx)(Oe.CancellationsSection,{items:Pl,dayWord:dl?ul?cl.toLowerCase():`on ${cl}`:'today'})]}),on=(0,Ye.jsx)(U.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:nn}),an=F.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&bs(!1)}}),rn=(0,Ye.jsxs)(V.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${ln}, ${tn.length}`,accessibilityState:{expanded:gs},'aria-expanded':gs,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>bs(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:gs?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?le.colours.tilePressed:gs?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ye.jsx)(Q.T,{size:16,weight:"bold",colour:le.colours.gold,children:tn.length}),(0,Ye.jsx)(K.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(K.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ye.jsxs)(Q.T,{size:13,weight:"semibold",colour:le.colours.goldLight,numberOfLines:1,children:[ln," ",gs?'\u2039':'\u203a']})})})]}),dn=Math.min(560,Math.max(320,.44*rt))<400,cn=gs?(0,Ye.jsxs)(K.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ye.jsxs)(K.default,{testID:"guests-drawer",...an.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*rt)),backgroundColor:le.colours.surface,borderRightWidth:1,borderColor:le.colours.gold,borderRadius:14,..._e.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ye.jsxs)(K.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ye.jsxs)(K.default,{testID:"guests-heading-row",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsxs)(K.default,{style:{flex:1,minWidth:0,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,paddingRight:4},children:[(0,Ye.jsxs)(Q.T,{testID:"guests-heading",size:dn?14:17,weight:"semibold",colour:le.colours.gold,style:{flexShrink:1,minWidth:0},children:[ln.toUpperCase()," (",tn.length,")"]}),(0,Ye.jsx)(V.default,{testID:"guest-key-button",accessibilityRole:"button",accessibilityLabel:"Guest key",accessibilityState:{expanded:us},'aria-expanded':us,onPress:()=>hs(e=>!e),style:({pressed:e})=>({minHeight:44,paddingHorizontal:dn?8:12,borderRadius:12,borderWidth:1,borderColor:us?le.colours.gold:le.colours.hairline,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e?le.colours.tilePressed:us?le.colours.goldTint:'rgba(255,255,255,0.03)'}),children:(0,Ye.jsxs)(Q.T,{size:14,weight:"semibold",colour:le.colours.goldLight,children:[dn?'Key':'Guest key'," ",us?'\u25b4':'\u25be']})})]}),(0,Ye.jsx)(s.GoldClose,{testID:"guests-close",label:`Close ${ln}`,onPress:()=>bs(!1),style:{marginRight:-6,flexShrink:0}})]}),Hl.count?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,testID:"cancelled-day-tally-guests",children:Ml}):null,us?(0,Ye.jsxs)(K.default,{testID:"guest-key",accessible:!0,accessibilityLabel:"Guest key: yellow triangle allergy, gold dog, star VIP, heart regular, cake birthday, heart with ribbon anniversary",style:{marginTop:6,padding:10,borderRadius:12,borderWidth:1,borderColor:le.colours.hairline,flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8},children:[(0,Ye.jsxs)(K.default,{testID:"guest-key-allergy",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{testID:"guest-key-dog",style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),[['\u2605','VIP'],['\u2665','regular'],['\ud83c\udf82','birthday'],['\ud83d\udc9d','anniversary']].map(([e,t])=>(0,Ye.jsxs)(K.default,{testID:`guest-key-${t}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(Q.T,{size:16,children:e}),(0,Ye.jsx)(Q.T,{size:14,children:t})]},t))]}):null]}),on]}),(0,Ye.jsx)(V.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${ln}`,accessibilityRole:"button",onPress:()=>bs(!1),style:{flex:1}})]}):null,un=jl?wl:l.IS_KIRKTON&&!Object.values(wt.kitchenHours??{}).some(Boolean)?(0,Ye.jsxs)(K.default,{testID:"kirkton-hours-to-confirm",style:[_e.look.panel,{padding:14,gap:8}],children:[(0,Ye.jsx)(Q.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ye.jsx)(Q.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ye.jsx)(Le.DayGraph,{busyThreshold:(0,t.venueBusy)(wt,kt,Ct).busy,todays:hl,open:yl,close:pl,now:Ct,turnBase:wt.settings.turnMins,blocks:Al,pauses:xl,compact:ut,dense:!ut,fit:gt,tight:gt&&ct<=600,height:gt?Si:vi,forecastNote:dl?void 0:Jl,emptyText:Il,past:rl{vs.current=Date.now(),Ds(!0)},shortDay:!ut&&rt<1100}),bn=(0,Ye.jsx)(Pe.DisplayCalendar,{visible:ks,today:Pt,day:rl,bookings:kt,restaurant:wt,now:Ct,onDay:Ss,onClose:()=>Ds(!1)}),yn=()=>{dl?bs(!0):qt(!0)},pn=(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',padding:Hi?4:ct<820?8:12,paddingTop:Hi?Di?2:4:ct<820?Di?4:6:Di?8:10,gap:Hi?8:12,minHeight:0,overflow:'hidden'},children:[Mt?null:rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Mt?null:pi,Mt?(0,Ye.jsx)(U.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"})}):bi?gi:hi,yi,cn]}),(0,Ye.jsxs)(K.default,{testID:"display-side",style:{width:yt,gap:ct<820?4:8,minHeight:0},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:ki(!1)}),(0,Ye.jsx)(K.default,{style:{flexShrink:0},children:wi}),Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",onLayout:Ji,style:Di&&!Ui?{flexGrow:1,flexShrink:0,minHeight:0}:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:ct<820,snug:ct<820,tight:ct<800,fill:Di&&!Ui,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{ref:Ri,testID:"day-graph-slot",onLayout:Ji,style:{flexGrow:0,flexShrink:Di?0:1,flexBasis:(ut?vi:Si)+(Di?Ai:Pi),height:(ut?vi:Si)+(Di?Ai:Pi),minHeight:ct<=600?90:Math.min((ut?vi:Si)+Le.DAY_GRAPH_CHROME,!ut&&ct>=768?140+Le.DAY_GRAPH_CHROME:120),overflow:'visible'},children:hn}),Di&&!Mt?(0,Ye.jsx)(K.default,{ref:Bi,testID:"display-side-split",onLayout:Ji,style:{flexShrink:0,alignItems:'center'},children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})}):null,(0,Ye.jsxs)(U.default,{testID:"display-side-scroll",style:Di?{flexGrow:0,flexShrink:1,minHeight:Li&&Ei?44:0}:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},onContentSizeChange:(e,t)=>{const s=t>10;s!==Wi.current&&(Wi.current=s,zi(s),setTimeout(Ji,0))},children:[Di||mi?null:(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),Zi,(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt})]})]})]});return(0,Ye.jsxs)(Y.SafeAreaView,{style:{flex:1,backgroundColor:le.colours.bg},onTouchStart:()=>{vs.current=Date.now()},onMouseDown:()=>{vs.current=Date.now()},children:[ut?(0,Ye.jsx)(K.default,{style:{flex:1},children:(0,Ye.jsxs)(U.default,{ref:pt,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ye.jsxs)(K.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ye.jsx)(K.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ye.jsx)(j.ExitButton,{})}),(0,Ye.jsx)(Z.RestaurantLogo,{rid:jt,size:64}),(0,Ye.jsx)(Q.T,{center:!0,size:24,weight:"bold",accessibilityRole:"header",children:wt.name}),(0,Ye.jsx)(Z.PoweredBy,{}),(0,Ye.jsx)(z.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ye.jsx)(K.default,{accessible:!0,accessibilityLabel:`Current time ${(0,te.hm)(Ct)}`,children:(0,Ye.jsx)(Q.T,{center:!0,size:30,weight:"semibold",colour:le.colours.goldLight,children:(0,te.hm)(Ct)})}),(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:"m"}),(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",size:"m"}),ee]}),Ve,k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt}),gn,(0,Ye.jsx)(K.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ye.jsx)(nt,{phone:!0,split:zl,items:[{label:`Tables \xb7 ${cl}`,value:Wl.length,testID:'badge-tables'},{label:`Covers \xb7 ${cl}`,value:Ll,testID:'badge-covers'},{label:'Takeaway',value:Ys.length,alert:Ys.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>is(!0)}]})}),(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{gap:8},children:ki(!0)}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),wi,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[bi?gi:hi,yi]}),(0,Ye.jsxs)(K.default,{onLayout:e=>{ft.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[_e.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ye.jsxs)(Q.T,{center:!0,size:20,weight:"semibold",colour:le.colours.goldLight,accessibilityRole:"header",children:[ln," (",tn.length,")"]}),(0,Ye.jsx)(K.default,{testID:"display-guest-list",accessibilityLabel:ln,style:{gap:4},children:nn})]}),Zi,hn,(0,Ye.jsx)(K.default,{testID:"covers-dock",children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,compact:!0,sound:(0,O.flapSoundOn)(),onPress:()=>pt.current?.scrollTo({y:ft.current,animated:!0})})}),(0,Ye.jsxs)(K.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ye.jsx)(Q.T,{center:!0,size:14,colour:Et?le.colours.muted:le.colours.amber,children:Et?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ye.jsx)(Q.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>$s(!0),style:{minHeight:48,alignSelf:'stretch'}}),mi?null:(0,Ye.jsx)(Q.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>Ws(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),Xi]})}):(0,Ye.jsxs)(Ye.Fragment,{children:[Di?(0,Ye.jsx)(K.default,{testID:"display-whos-on-top",style:{flexShrink:0,width:'100%',maxWidth:'100%',flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,minHeight:44,maxHeight:44,overflow:'hidden',backgroundColor:(0,o.soutersSurface)('#0D0D0C'),borderBottomWidth:1,borderBottomColor:le.colours.hairline},children:(0,Ye.jsx)(K.default,{style:{flex:1,minWidth:0,maxHeight:44,overflow:'hidden',justifyContent:'center'},children:(0,Ye.jsx)(w.WhosOnShift,{compact:!0,marquee:!0})})}):null,(0,Ye.jsxs)(K.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:rt>=1e3?18:14,paddingVertical:Hi?2:ct<820?4:8,gap:8,minHeight:Hi&&Di?44:52,backgroundColor:(0,o.soutersSurface)('#0D0D0C'),..._e.look.web({backgroundImage:l.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-left",style:{flex:1,flexDirection:'row',alignItems:'center',gap:Di?16:8,minWidth:0,overflow:'hidden',...Di?{justifyContent:'flex-start'}:null},children:[(0,Ye.jsx)(K.default,{testID:"display-header-brand",style:Di?{flexShrink:1,minWidth:96,maxWidth:280}:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ye.jsx)(Z.RestaurantBrand,{rid:wt.id,size:rt<900?32:40,beside:!0,noLogo:Di})}),(0,Ye.jsxs)(K.default,{testID:"display-header-time",style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ye.jsx)(Q.T,{size:rt<900?18:21,weight:"semibold",colour:le.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,te.hm)(Ct)}),rt>=900?(0,Ye.jsx)(Q.T,{size:13,colour:le.colours.muted,children:(0,te.niceDate)(Ct)}):null]})]}),Mt?(0,Ye.jsx)(K.default,{style:{width:220}}):(0,Ye.jsx)(K.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gn}),(0,Ye.jsxs)(K.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ye.jsxs)(K.default,{testID:"display-header-chips",style:{flexDirection:rt>=1400||Di?'row':'column',alignItems:rt>=1400||Di?'center':'flex-end',justifyContent:'center',gap:6,flexShrink:0},children:[(0,Ye.jsx)(Fe.ShellfishChip,{rid:jt,by:zt,app:"display",size:rt<1240?'xs':rt<1280||ct<700?'s':'m'}),Mt?null:(0,Ye.jsx)(Fe.SundayRoastChip,{rid:jt,by:zt,app:"display",slot:Di,size:rt<1340?'xs':rt<1400||ct<700?'s':'m'})]}),'simulated'===St?(0,Ye.jsx)(V.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>vt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(Q.T,{size:11,colour:le.colours.muted,children:"+15"})}):null,ee,e?null:(0,Ye.jsx)(K.default,{testID:"display-exit-slot",style:{width:44,height:44,flexShrink:0,alignItems:'center',justifyContent:'center'},children:(0,Ye.jsx)(j.ExitButton,{size:44})})]})]}),Ve,k.IS_CAR||!Mt||Di?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(ke.BookingSaveBanner,{rid:jt,margin:{marginHorizontal:12,marginTop:6}}),Mt||Di?null:(0,Ye.jsx)(K.default,{testID:"display-day-stats",style:Ze,children:(0,Ye.jsxs)(K.default,{style:et,children:[k.IS_CAR?null:(0,Ye.jsx)(w.WhosOnShift,{compact:!0}),(0,Ye.jsx)(K.default,{style:tt,children:(0,Ye.jsx)(nt,{splitOnly:!0,split:zl,items:[]})})]})}),gt?pn:(fn=(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsxs)(K.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ye.jsx)(K.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:ki(!1)}),wi]}),(0,Ye.jsx)(We.BlocksBanner,{rid:jt,now:Ct,big:!0,by:zt}),Mt?(0,Ye.jsx)(A.DayView,{rid:jt,day:Mt,today:Pt,app:"display"}):(0,Ye.jsx)(Ye.Fragment,{children:(0,Ye.jsxs)(K.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[rn,(0,Ye.jsxs)(K.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[pi,bi?gi:hi,yi,cn]})]})}),Zi,Mt?null:(0,Ye.jsx)(K.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ye.jsx)(M.CoversToday,{rid:jt,day:rl,sound:(0,O.flapSoundOn)(),onPress:yn})}),Mt?null:(0,Ye.jsx)(K.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:vi+Le.DAY_GRAPH_CHROME},children:hn})]}),(0,Ye.jsx)(U.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:fn})),Xi]}),(0,Ye.jsx)($.SoldOutStrip,{rid:jt,by:Ht,onOpen:()=>Ps(!0)}),(0,Ye.jsx)(B.SoldOutSheet,{visible:Hs,onClose:()=>Ps(!1),rid:jt,by:Ht,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ye.jsx)(p.TableOrderCue,{rid:jt}),At.elements,ns?(0,Ye.jsx)(y.EditBookingPicker,{rid:jt,today:Pt,who:zt,onClose:()=>os(!1)}):null,as?(0,Ye.jsx)(y.EditBookingSheet,{rid:jt,id:as,who:zt,onClose:()=>rs(null)}):null,Jt?(0,Ye.jsx)(Se.TableSheet,{rid:jt,name:Jt,view:Zs,plan:_t,todays:Ks,now:Ct,privacy:Et,turnBase:wt.settings.turnMins,onClose:()=>Xt(null),onWalkIn:e=>At.openWalkInAt(e),onMove:e=>es(e),onDetails:Us}):null,Dl?(()=>{const e=kl[Dl],t=e?.dayBookings??[];return(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>{Bl(null),vl(null)},title:`${(0,d.tableNumbersA11y)(Dl)} \xb7 ${ul?cl:(0,He.dayLong)(rl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ye.jsxs)(Q.T,{size:16,center:!0,colour:le.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${ul?cl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${ul?cl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,xe.privName)(e,Et):st(e.name);return(0,Ye.jsx)(Q.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,De.tablesWords)((0,re.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{vl(null),xs(e.id)},style:{minHeight:56}},e.id)}),rl>=Pt?(()=>{const t=e?.table.maxSeats??0,s=kt.filter(e=>e.date===rl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,re.tablesOf)(e.table).includes(Dl)).sort((e,t)=>e.time.localeCompare(t.time));return s.length?(0,Ye.jsxs)(K.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ye.jsxs)(Q.T,{size:17,weight:"semibold",center:!0,colour:le.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(Dl)]}),$l?(0,Ye.jsxs)(K.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:$l.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:le.colours.amber,backgroundColor:le.colours.amberBg},children:[(0,Ye.jsx)(Q.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:$l.ask}),(0,Ye.jsxs)(Q.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ii.ok,accessibilityHint:Ii.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=kt.find(e=>e.id===$l.id);if(Bl(null),!e)return;const s=st(e.name);vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es)}}),(0,Ye.jsx)(Q.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>Bl(null)})]})]}):null,$l?null:s.slice(0,12).map(e=>{const s=st(e.name),l=e.partySize>t;return(0,Ye.jsx)(Q.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${s} \xb7 ${e.partySize} Covers`,sub:l?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ii.ok,accessibilityHint:Ii.hint,accessibilityLabel:`Put ${s}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(Dl)}${l?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,ke.guardBookingChange)(Es,{b:e,tables:[Dl]}))return;const l=(0,De.overCapacityAsk)([Dl],t,e.partySize);l?Bl({id:e.id,ask:l}):(vl(null),await(0,ke.saveTablesReported)(jt,e,[Dl],s,t,Es))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ye.jsx)(Q.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{Bl(null),vl(null)},style:{minHeight:56}})]})})():null,fs?(()=>{const e=kt.find(e=>e.id===fs);return e?(0,Ye.jsx)(we.GuestActionsSheet,{rid:jt,b:e,name:e.walkIn?(0,xe.privName)(e,Et):st(e.name),view:Zs,now:Ct,otherDay:e.date!==Pt,turnBase:wt.settings.turnMins,onClose:()=>xs(null),onDetails:Us,onDone:Es,onEdit:e=>{xs(null),rs(e.id)},onPickOnPlan:(e,t)=>{bs(!1),Ut('plan'),Qt('all'),js({id:e.id,tables:t})}}):null})():null,ts?(0,Ye.jsx)(Se.DetailsPanel,{title:ts.title,onClose:()=>ss(null),children:ts.body}):null,bn,ds?(0,Ye.jsx)(Se.ServiceSummary,{r:wt,todays:Ks,orders:It,waitlistAll:Cs,walkInCount:Ts,onClose:()=>cs(!1)}):null,Rs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>$s(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ye.jsx)(g.FloorLegend,{}),(0,Ye.jsxs)(K.default,{testID:"colour-key-symbols",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',columnGap:16,rowGap:8,paddingVertical:4},children:[(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(N.AllergyIcon,{text:"allergy",size:18,colour:le.colours.amber,ink:le.colours.bg}),(0,Ye.jsx)(Q.T,{size:14,children:"allergy"})]}),(0,Ye.jsxs)(K.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,Ye.jsx)(je.DogIcon,{size:18}),(0,Ye.jsx)(Q.T,{size:14,children:"dog"})]}),(0,Ye.jsx)(Q.T,{center:!0,size:14,children:"\u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>$s(!1)})]}):null,Ls?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>zs(!1),title:"More",maxWidth:480,testID:"display-more-sheet",children:[(0,Ye.jsx)(V.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>{zs(!1),Ws(!0)},style:{minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ye.jsx)(Q.T,{center:!0,weight:"semibold",children:"Reviews"})}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>zs(!1)})]}):null,Bs?(0,Ye.jsxs)(Q.Sheet,{visible:!0,onClose:()=>Ws(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ye.jsx)(J.ReviewsSection,{rid:jt,mode:"read",venueName:wt.name}),(0,Ye.jsx)(Q.Button,{kind:"secondary",label:"Close",onPress:()=>Ws(!1)})]}):null,ls?(0,Ye.jsxs)(Se.DetailsPanel,{title:"Takeaway",onClose:()=>is(!1),children:[(0,Ye.jsx)(Q.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ye.jsx)(at,{list:Ys,me:zt,bookings:kt})]}):null,Ns?(0,Ye.jsx)(K.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:le.colours.bg},children:(0,Ye.jsx)(ge.PlanDesigner,{initial:_t,venue:wt.name,mode:"display",startStep:"arrange",onActivity:()=>{Gs.current=Date.now(),null!==Fs&&Vs(null)},notice:null!==Fs?`Locking again in ${Fs} s \xb7 touch to keep editing`:null,onSave:e=>{re.useFloor.getState().setPlan(jt,e),_s(null),Es('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{re.useFloor.getState().setPlan(jt,e),Es('Live seating plan updated on every screen.')},onCancel:()=>{_s(null),Es('No changes kept. Editing is locked again.')}},Ns.at)}):null,e?null:(0,Ye.jsx)(pe.Screensaver,{rid:jt,idleMins:Ot.idleMins,pinOn:Ot.pinOn,wake:Ot,tonightCards:Ot.tonightCards,cfg:Nt}),e?null:(0,Ye.jsx)(Te.PrintHost,{rid:jt}),e?null:(0,Ye.jsx)(Ce.AlertHost,{variant:"display",rid:jt,skipTakeaway:!0}),e?null:(0,Ye.jsx)(E.SeatAllergenReminder,{rid:jt}),e?null:(0,Ye.jsx)(Re.TakeawayTakeover,{rid:jt,me:zt})]});var fn}function dt({rid:e,id:t,turnBase:s}){const l=(0,se.useBookings)(e).find(e=>e.id===t);return l?(0,Ye.jsx)(b.BookingTableButton,{rid:e,booking:l,turnBase:s}):null}},1334,[1053,779,805,806,1335,813,1336,1094,843,1140,1337,1338,1339,1091,1122,1340,1341,1346,1347,1204,1348,856,1353,1354,1355,1115,1113,920,1356,1153,891,1104,1357,17,1072,1179,1018,1087,1358,21,378,363,385,278,85,409,19,777,1231,1235,857,845,863,858,804,1090,876,1098,1057,998,1076,1109,1359,1108,1360,1366,1368,1372,1377,1371,1378,1381,1382,1117,1095,1096,862,1387,1220,1388,1230,1222,995,1393,1398,1399,1054,1052,1119,1401,1402,1403,1071,1172,1404,1171,1162,853,1349,1405,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1337,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1338,[996,1057]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1339,[17,85,1076,777,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1340,[843,17,85,777,858,1154,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}),Object.defineProperty(_e,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1341,[17,378,385,409,85,1275,777,1172,779,998,1342,1343,1345,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1342,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1343,[17,378,385,278,395,85,409,779,777,804,1344,1345,8]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1344,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1345,[993,856,1344,928,899]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1346,[831]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function({size:e}={}){const[D,E]=(0,o.useState)(!1),[I,v]=(0,o.useState)(!1),_=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);const R=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:D?y:f,onPress:()=>{if(!D)return E(!0),_.current&&clearTimeout(_.current),void(_.current=setTimeout(()=>E(!1),j));_.current&&clearTimeout(_.current),E(!1);const e=C();if(e)try{e.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}v(!0)}},hitSlop:6,style:({pressed:t})=>({...p.look.quiet(t),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:e?0:8,...e?{width:e,height:e,borderRadius:e/2}:null,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:D?'semibold':'regular',colour:D?b.colours.gold:b.colours.muted,children:D?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:I,transparent:!0,animationType:"fade",onRequestClose:()=>v(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),R?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[R?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>v(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1347,[813,17,362,378,385,85,777,1172,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}),Object.defineProperty(_e,"hh",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return j}}),_e.rotaDay=C,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:t,staff:r,today:a,leave:c,fill:d=!1}){const[h,u]=(0,s.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start',...d?{flex:1,alignSelf:'stretch'}:null},children:[(0,b.jsx)(i.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. Tap a kitchen name to assign a kitchen role.",onPress:()=>u('rota'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,b.jsx)(n.T,{size:e?16:13,weight:"semibold",colour:l.colours.goldLight,children:"Rota"})}),(0,b.jsx)(i.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen use only",accessibilityHint:"Opens the Head Chef app: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[D,{flex:e||d?1:void 0,backgroundColor:t?l.colours.goldTint:'rgba(255,255,255,0.035)'}],children:e?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:S}):(0,b.jsxs)(o.default,{style:{alignItems:'center'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:l.colours.goldLight,style:{lineHeight:15},children:"Kitchen"}),(0,b.jsx)(n.T,{size:11,colour:l.colours.goldLight,style:{lineHeight:13},children:"use only"})]})})]}),'rota'===h?(0,b.jsx)(v,{shifts:t,staff:r,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,b.jsx)(I,{onClose:()=>u(null)}):null]})},Object.defineProperty(_e,"KITCHEN_LABEL",{enumerable:!0,get:function(){return S}}),_e.chefFromDisplayUrl=function(e){return e.includes('?')?e.replace('?','?from=display&'):e.replace(/(#|$)/,'?from=display$1')},Object.defineProperty(_e,"KITCHEN_ROLE_ERRORS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"KITCHEN_UNLOCK_ERRORS",{enumerable:!0,get:function(){return T}});var t=_r(_d[0]),s=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]);const p=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],m=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],k=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},x=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,j=e=>!!e&&x.test(`${e.dept??''} ${e.job??''}`);function C(e,s,i,o){const n=new Map(s.map(e=>[e.id,e]));return e.filter(e=>e.date===i&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const s=n.get(e.staffId),i=o?.length?(0,y.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:s?.nickname||s?.name||'Team member',job:s?.job??'',kitchen:j(s),from:k(e.start),to:k(e.end),note:e.note??'',badge:(0,t.cleanBadge)(e.badge)??'',off:i?(0,y.leaveLabel)(i):''}})}const D={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:l.colours.accentBorder};function v({shifts:e,staff:c,today:d,leave:u,onClose:k}){const[x,j]=(0,s.useState)(d),D=(0,a.mondayOfDate)(x),v=(0,s.useMemo)(()=>p.map((e,t)=>(0,a.addDays)(D,t)),[D]),S=(0,s.useMemo)(()=>C(e,c,x,u),[e,c,x,u]),T=(0,s.useMemo)(()=>v.map(t=>(0,y.workingShifts)(e,u).filter(e=>e.date===t&&e.published).length),[v,e,u]),$=(0,a.weekdayOf)(x),I=`${x===d?'Today, ':''}${m[$]} ${(0,f.niceDate)((0,f.parseYmd)(x)).replace(/^\S+ /,'')}`,[H,O]=(0,s.useState)(null),[L,R]=(0,s.useState)(''),[P,_]=(0,s.useState)(!1),M=async e=>{if(!H||P)return;_(!0),R('');const s=await(0,h.displayAssignKitchenRole)(H.id,e);_(!1),s.ok?(a.useOwner.getState().setShifts((0,t.applyLiveKitchenBadge)(a.useOwner.getState().shifts,H.id,e)),O(null)):R(w[s.error]||w.offline)},K=e=>`${e.name}${e.job?`, ${e.job}`:''}${e.badge?`, on ${e.badge}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,z=(e,t,s)=>t.length?(0,b.jsxs)(o.default,{style:{gap:6},children:[(0,b.jsx)(n.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>{const t=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,b.jsx)(n.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note||e.badge?(0,b.jsx)(n.Muted,{numberOfLines:1,center:!1,children:[e.badge?`On ${e.badge}`:'',e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,b.jsx)(n.T,{size:16,weight:"semibold",colour:l.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,b.jsxs)(n.T,{size:16,weight:"semibold",colour:l.colours.goldLight,children:[e.from,"\u2013",e.to]})]}),r={flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:l.colours.hairline};return s&&!e.off?(0,b.jsx)(i.default,{testID:`rota-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${K(e)}. Assign a kitchen role`,accessibilityHint:"Opens Assign a role? for this kitchen shift",onPress:()=>{R(''),O(e)},style:({pressed:e})=>[r,{backgroundColor:e?l.colours.goldTint:'transparent'}],children:t},e.id):(0,b.jsx)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:K(e),style:r,children:t},e.id)})]},e):null;return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:k,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,b.jsx)(n.Muted,{children:"Tap a kitchen name to assign a kitchen role. Front of house roles are set in Cover Charge for Managers."}),(0,b.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>j((0,a.addDays)(x,-7)),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>j(d),style:{minHeight:48,flex:1}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>j((0,a.addDays)(x,7)),style:{minHeight:48,flex:1}})]}),(0,b.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:v.map((e,t)=>{const s=e===x;return(0,b.jsxs)(i.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`${m[t]} ${(0,f.niceDate)((0,f.parseYmd)(e)).replace(/^\S+ /,'')}${e===d?', today':''}, ${T[t]} on`,onPress:()=>j(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:s?l.colours.gold:l.colours.hairline,backgroundColor:s?l.colours.gold:'transparent'},children:[(0,b.jsx)(n.T,{size:13,weight:"semibold",colour:s?l.colours.bg:e===d?l.colours.goldLight:l.colours.text,children:p[t]}),(0,b.jsx)(n.T,{size:12,colour:s?l.colours.bg:l.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,b.jsxs)(n.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[I," \xb7 ",S.filter(e=>!e.off).length," on",S.some(e=>e.off)?` \xb7 ${S.filter(e=>e.off).length} on time off`:'']}),S.length?(0,b.jsxs)(b.Fragment,{children:[z('KITCHEN',S.filter(e=>e.kitchen),!0),z('FRONT OF HOUSE',S.filter(e=>!e.kitchen),!1)]}):(0,b.jsx)(n.Muted,{testID:"rota-empty",children:"No published shifts this day."}),L?(0,b.jsx)(o.default,{testID:"display-role-err",accessibilityLiveRegion:"assertive",children:(0,b.jsx)(n.T,{center:!0,colour:l.colours.amber,children:L})}):null,H?(0,b.jsx)(r.AssignRoleSheet,{name:H.name,when:`${H.from}\u2013${H.to}`,current:H.badge,roles:t.KITCHEN_ROLE_BADGES,onSave:e=>{M(e)},onClose:()=>O(null)}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:k,style:{minHeight:48}})]})}const S='Kitchen use only';const w={not_display:'This only works on the paired Display.',not_kitchen:'Kitchen roles are only for the kitchen team.',not_kitchen_role:'Choose a kitchen role, or None.',missing:'That shift is not on the published rota.',offline:'Could not reach the server. Check the connection and try again.'},T={wrong:'That code is wrong.',locked:'Too many tries. Wait 15 minutes and try again.',not_display:'This Display is not paired.',not_set:'This is not set up yet. Ask Gordon.',offline:'Could not reach the server. Check the connection and try again.'},$=()=>'undefined'!=typeof navigator&&/; wv\)|CoverChargeDisplay/i.test(navigator.userAgent||'');function I({onClose:e}){const t=(0,c.appUrl)('chef'),[i,r]=(0,s.useState)(null),[l,a]=(0,s.useState)(!1),[f,y]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),k=e=>{if($())return void window.location.assign(e);const t=window.open(e,'_blank');if(t)try{t.opener=null}catch{}else window.location.assign(e)},x=async e=>{if(f)return;y(!0),m(null);const s=await(0,h.displayKitchenUnlock)(e);y(!1),s.ok?t?k((0,u.chefKitchenUrl)(t,s.ticket)):r('Open Cover Charge for Head Chef on this device.'):m(T[s.error]||T.offline)};return(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:S,maxWidth:560,testID:"display-kitchen-sheet",children:[(0,b.jsx)(n.Muted,{center:!0,children:"For the kitchen team. Type the Display unlock code to open Cover Charge for Head Chef, already signed in as the Head Chef. Back to Display is on every screen. After you go back or leave it idle, the code is needed again."}),(0,b.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, CookSafe and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, CookSafe and kitchen checks'].map(e=>(0,b.jsxs)(n.T,{size:15,center:!0,children:["\u2022 ",e]},e))}),l?(0,b.jsx)(d.PinPad,{title:"Unlock for the kitchen",sub:"Four-digit Display code",onDone:e=>{x(e)},error:p,busy:f,length:4}):(0,b.jsx)(n.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Asks for the Display unlock code, then opens the Head Chef app signed in.",onPress:()=>{t?(m(null),a(!0)):r('Open Cover Charge for Head Chef on this device.')},style:{minHeight:56}}),i?(0,b.jsx)(n.Muted,{center:!0,children:i}):null,(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1348,[1168,17,219,385,85,777,1167,804,876,920,1349,899,922,863,1071,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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,j.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,j.jsx)(T,{onClose:()=>t(!1)}):null]})},_e.PinPad=I,_e.DisplayClockSheet=T,_e.TempCode=C,_e.AddTempForm=M;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]);const D=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),w={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function I({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,y=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},k=f?Math.max(c??4,p.length):r,x=(e,t,n)=>(0,j.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,j.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,j.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,j.jsx)(u.Muted,{children:t}):null,(0,j.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:k},(e,t)=>t).map(e=>(0,j.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,j.jsx)(u.Row,{gap:10,children:e.map(e=>x(e,()=>y(e),`pin-key-${e}`))},e.join())),(0,j.jsxs)(u.Row,{gap:10,children:[f?x('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,j.jsx)(d.default,{style:{width:84}}),x('0',()=>y('0'),'pin-key-0'),x('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function T({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,y.useDisplayTiles)(e=>e.tiles),x=(0,y.useDisplayTiles)(e=>e.managers),T=(0,y.useDisplayTiles)(e=>e.lens),P=e=>T[e]?.len??4,S=(0,k.useSync)(e=>'device'===e.kind)||s.PITCH,[v,B]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,y.refreshTiles)(),(0,y.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[v,e]),(0,l.useEffect)(()=>{if('done'!==v.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[v,e]);const Y=(0,l.useMemo)(()=>r??(0,y.localTiles)(o,D()),[r,o]),_=S?x:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),B(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,y.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,y.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${w[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,y.refreshTiles)(),E({s:'done',text:`${e.name} ${w[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,y.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,y.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===v.s){const e=n>=1100?4:n>=760?3:2;K=(0,j.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),S?null:(0,j.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,j.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,j.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,j.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,j.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,j.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,j.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,j.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,j.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===v.s){const e=v.t;O=`Hello ${e.name}`,K=(0,j.jsx)(I,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===v.s){const{t:e,pin:t,st:n}=v;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,j.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,j.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,j.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,j.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,j.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,j.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,j.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===v.s){const{t:t,pin:n}=v;O='Do you want to sign in?',K=(0,j.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,j.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,j.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,j.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,j.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===v.s){const{t:e,pin:t,worked:n}=v;O='Did you take a break? If so, how long?',K=(0,j.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,j.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,j.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,j.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,j.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===v.s){const{t:e,pin:t,first:n}=v;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,T[W]?.min??4);K=(0,j.jsx)(I,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,y.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void B({s:'newpin',t:e,pin:t});L(!0);const r=await(0,y.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,y.errorText)(r.error,r))}})}else if('done'===v.s)O='Done',K=(0,j.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,j.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:v.text}),(0,j.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===v.s)O='Add temp staff',K=(0,j.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,j.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,j.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,j.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,j.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,j.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===v.s){const e=v.m;O='Manager PIN',K=(0,j.jsx)(I,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===v.s){const{m:e,pin:t}=v;O='Add temp staff',K=(0,j.jsx)(M,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,y.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,y.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||B({s:'mgrpin',m:e}));(0,y.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===v.s&&(O='Temp added',K=(0,j.jsx)(C,{name:v.name,code:v.code,onClose:e}));var W;return(0,j.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===v.s?1100:560,testID:"display-clock-sheet",children:(0,j.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function C({name:e,code:t,onClose:n}){return(0,j.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,j.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,j.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,j.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,j.jsx)(u.Button,{label:"Done",onPress:n})]})}const P=['Kitchen','Front of house','Bar'],S=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function M({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(''),[k,D]=(0,l.useState)(''),w=b.trim()?(0,x.parseMoneyInput)(b):null,I=null!=w&&(!Number.isFinite(w)||w<0||w>200),T=!!k&&(!/^\d{4}-\d{2}-\d{2}$/.test(k)||k(0,j.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,j.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:e=>y((0,x.sanitiseMoneyTyping)(e)),placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",inputMode:"decimal",style:C}),I?(0,j.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,j.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,j.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',S(0)],['In 1 week',S(7)],['In 2 weeks',S(14)]].map(([e,t])=>(0,j.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:k===t,onPress:()=>D(t)},e))}),(0,j.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(k,D),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:C}),T?(0,j.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",S(7),"."]}):null,(0,j.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,j.jsx)(d.default,{testID:"temp-error",children:(0,j.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,j.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||I||T,onPress:()=>e({name:c.trim(),dept:m,rate:w,until:k||null})})]})}},1349,[813,1033,812,880,1172,17,385,85,409,777,804,876,913,863,916,1350,899,840,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),r=_r(d[3]),a=_r(d[4]),o=_r(d[5]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1350,[831,928,899,1351,880,1352]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1351,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(t,c){return}},1352,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.displayActionBy=function(t){if(t.isCar)return'Car';if(t.isDisplayApp)return'Display';return(t.personName??'').trim()||'Duty Manager'}},1353,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"finishClearPatch",{enumerable:!0,get:function(){return s.finishClearPatch}}),Object.defineProperty(e,"DEFAULT_TURN_MINS",{enumerable:!0,get:function(){return a}}),e.bookingEndAt=u,e.isLeftEarly=o,e.todaysGuestList=function(t,n,s=a){return t.filter(t=>'confirmed'===t.status||'seated'===t.status||o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))},e.todaysFinishedList=function(t,n,s=a){return t.filter(t=>'finished'===t.status&&!o(t,n,s)).sort((t,n)=>t.time.localeCompare(n.time))};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const a=90;function u(s,u=a){if(!s.date||!s.time)return null;const o=(0,n.atTime)((0,n.parseYmd)(s.date),s.time),f=u>0?u:a,c=s.durationMins&&s.durationMins>=15?s.durationMins:(0,t.turnFor)(s.partySize??2,f);return new Date(o.getTime()+6e4*c)}function o(t,s,o=a){if('finished'!==t.status||!t.date||!t.time||!t.finishedAt)return!1;const f=(0,n.atTime)((0,n.parseYmd)(t.date),t.time);if(new Date(t.finishedAt).getTime()>=f.getTime())return!1;const c=u(t,o);return!!c&&(s??new Date).getTime()1?'are':'is'} free again`:'',"."]}),(0,f.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,f.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${$}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>I(t,e,{stage:void 0,dirty:!1})),j(!1)}}),(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${$} seated`,onPress:()=>j(!1)})]})]}):(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${$}: ${e.walkIn?'removes the walk-in':'back to booked'}${v?`, frees ${v}`:''}`,onPress:()=>j(!0)});const L='undo-finished'===x?'seated':'confirmed';return(0,f.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===x?`Undo finished: ${$} back to seated${v?` at ${v}`:''}`:`Undo no-show: ${$} back to booked`,onPress:async()=>{'undo-finished'!==x?await n.repo.bookings.setStatus(e.id,L):await(0,b.undoFinishedNow)(t,e)}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),h=r(d[7]),f=r(d[8]);function k(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1355,[17,85,858,998,777,804,1115,1113,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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1356,[813,812,17,219,385,278,85,777,1153,858,891,816,893,894,856,892,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1357,[813,17,85,804,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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1358,[17,85,780,804,8]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1359,[]); +__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.cleanPlan=z,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),F=a.now,E=e=>l({t:'set',p:e}),[O,_]=(0,i.useState)(e.startStep??'areas'),[G,X]=(0,i.useState)(e.initial.areas[0]?.id??''),[K,J]=(0,i.useState)(null),q=(0,C.useOwner)(e=>e.site),V=(0,w.useFloor)(e=>e.settings[q]),Y=!1!==V?.gridSnap,Z=(0,y.gridOf)(V?.gridSize),Q=e=>w.useFloor.getState().setSettings(q,{...w.DEFAULT_SETTINGS,...V??{},gridSnap:e}),[ee,te]=(0,i.useState)(null),[se,ae]=(0,i.useState)(null),[le,oe]=(0,i.useState)(null),re=(0,I.useSync)(e=>e.venueId),ne=e.role??'staff',[ie,de]=(0,i.useState)(''),{width:ue,height:ce}=(0,c.default)(),he=ue>=900,be=a.past.length>0||JSON.stringify(F)!==JSON.stringify(e.initial),ge=(0,b.planCounts)(F);(0,i.useEffect)(()=>{F.areas.some(e=>e.id===G)||X(F.areas[0]?.id??'')},[F.areas,G]),(0,i.useEffect)(()=>{ie&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:ie,timeoutMs:3500,testID:'plan-toast'}),de(''))},[ie]);const pe='table'===K?.kind?F.tables.find(e=>e.id===K.id):void 0,xe='fixture'===K?.kind?(F.fixtures??[]).find(e=>e.id===K.id):void 0,me=(e,t)=>{const s=F.tables.find(t=>t.id===e),a=s&&t.name&&t.name!==s.name?F.joins.map(e=>({...e,tables:e.tables.map(e=>e===s.name?t.name:e)})):F.joins,l=s&&t.name&&t.name!==s.name?F.areas.map(e=>e.best?.includes(s.name)?{...e,best:e.best.map(e=>e===s.name?t.name:e)}:e):F.areas;E({...F,areas:l,joins:a,tables:F.tables.map(s=>s.id===e?{...s,...t}:s)})},fe=e=>{const t=F.tables.find(t=>t.id===e);E({...F,tables:F.tables.filter(t=>t.id!==e),joins:F.joins.filter(e=>!t||!e.tables.includes(t.name))}),J(null)},je=e=>{const t=b.FIXTURES.find(t=>t.id===e),s={id:(0,b.fid)('fx'),areaId:G,kind:e,x:25*Math.round((b.PLAN_W-t.w)/50),y:25,w:t.w,h:t.h};E({...F,fixtures:[...F.fixtures??[],s]}),J({kind:'fixture',id:s.id})},ye=e=>{const t=(0,y.tidyArea)(F,e,Z),s=(0,y.movedCount)(F,t);s?(E(t),de(`Tidied: ${s} table${1===s?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):de('Already tidy: every table is on the grid and lined up.')},we=e=>{const t=(0,b.autoArrange)(F.tables.filter(t=>t.areaId===e),M(F,e));E({...F,tables:[...F.tables.filter(t=>t.areaId!==e),...t]}),de('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const t=e.target?.tagName;if('INPUT'===t||'TEXTAREA'===t)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==O||!K)return;const s=e.altKey?1:Y?Z:5,a={ArrowLeft:[-s,0],ArrowRight:[s,0],ArrowUp:[0,-s],ArrowDown:[0,s]}[e.key];a&&(e.preventDefault(),Ce(K.kind,K.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===K.kind?fe(K.id):(E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==K.id)}),J(null))),'r'===e.key.toLowerCase()&&Te(K.kind,K.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const Ce=(e,t,s,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+s:s)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?{...e,...o(e)}:e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,...o(e)}:e)})},Te=(e,t)=>{E('table'===e?{...F,tables:F.tables.map(e=>e.id===t?(0,b.rotate90)(e):e)}:{...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?(0,b.rotate90)(e):e)})},Se=e=>{if(ee&&'table'===e?.kind&&e.id!==ee){const t=F.tables.find(e=>e.id===ee),s=F.tables.find(t=>t.id===e.id),a=F.joins.find(e=>e.tables.includes(t.name)),l=a?F.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,s.name])].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}:e).filter(e=>e===a||!e.tables.includes(s.name)):[...F.joins.filter(e=>!e.tables.includes(s.name)),{id:(0,b.fid)('j'),tables:[t.name,s.name].sort((e,t)=>(0,b.numOf)(e)-(0,b.numOf)(t))}];return E({...F,joins:l}),te(null),de(`Joined: book as ${l.find(e=>e.tables.includes(t.name)).tables.join('+')}`),void J(e)}te(null),J(e)},Ie='display'===e.mode;return(0,k.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[Ie?(0,k.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,k.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,k.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,k.jsx)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,k.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,k.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,k.jsxs)(h.default,{style:{marginRight:6},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,k.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,k.jsx)(x.Row,{gap:6,children:R.map(e=>{const t=e.id===O;return(0,k.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{_(e.id),J(null),te(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:t?p.colours.gold:p.colours.border,backgroundColor:t?p.colours.goldTint:'transparent'},children:[(0,k.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:t?p.colours.gold:p.colours.surface2},children:(0,k.jsx)(x.T,{size:13,weight:"bold",colour:t?p.colours.onGold:p.colours.muted,children:e.n})}),(0,k.jsx)(x.T,{weight:"semibold",size:15,colour:t?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,k.jsx)(h.default,{style:{flex:1}}),(0,k.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,k.jsxs)(x.T,{weight:"bold",size:16,children:[ge.tables," tables \xb7 ",ge.seats," seats"]}),(0,k.jsxs)(x.Muted,{size:12,children:[F.areas.length," area",1===F.areas.length?'':'s',be?' \xb7 unsaved changes':'']})]}),(0,k.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,k.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>be?ae({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,k.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!be,onPress:()=>ae({title:'Save changes to the table plan?',body:`${ge.tables} tables \xb7 ${ge.seats} seats across ${F.areas.length} area${1===F.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(z(F))}),style:{minHeight:44}}),re?(0,k.jsx)(S.NamedPlanButtons,{onSaveAs:()=>oe('save'),onList:()=>oe('list')}):null]}),(0,k.jsxs)(h.default,{style:{flex:1},children:['areas'===O?(0,k.jsx)(N,{plan:F,set:E,confirm:ae,wide:he,next:()=>_('tables'),toast:de}):null,'tables'===O?(0,k.jsx)(W,{plan:F,set:E,area:G,setArea:X,addTables:(e,t)=>{let s={...F,areas:[...F.areas],tables:[...F.tables]};const a=new Set(s.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const t of e){if(a.has(t.name)){l.push(t.name);continue}let e=G;if(t.area){const a=s.areas.find(e=>e.name.toLowerCase()===t.area.toLowerCase());a?e=a.id:(e=A(s,t.area),s.areas.push({id:e,name:t.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(t.name,e,t.seats,P(s,e)),[d]=(0,b.placeNew)(s.tables.filter(t=>t.areaId===e),[i],(s.fixtures??[]).filter(t=>t.areaId===e));s.tables.push(d),a.add(t.name),n.add(e),o++}if(t)for(const e of n){const t=s.tables.filter(t=>t.areaId===e),a=(0,b.autoArrange)(t,M(s,e));s={...s,tables:[...s.tables.filter(t=>t.areaId!==e),...a]}}return o&&E(s),de(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:fe,patch:me,wide:he,next:()=>_('arrange'),back:()=>_('areas')}):null,'arrange'===O?(()=>{const e=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(L,{plan:F,area:G,onPick:e=>{X(e),J(null),te(null)}}),ee?(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,k.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(F.tables.find(e=>e.id===ee)?.name),"."]}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>te(null)})]}):null,(0,k.jsx)(f.DesignerCanvas,{plan:F,areaId:G,sel:K,onSelect:Se,snapOn:Y,grid:Z,joinFrom:ee,fitWidth:!he,onMove:(e,t,s,a)=>Ce(e,t,s,a),onResize:(e,t,s,a)=>{if('table'===e){const e=F.tables.find(e=>e.id===t);if('round'===e.shape){const l=Math.max(s,a);me(t,{w:l,h:l,x:e.x,y:e.y})}else me(t,{w:s,h:a,shape:s===a?'square':'rect',x:e.x,y:e.y})}else E({...F,fixtures:(F.fixtures??[]).map(e=>e.id===t?{...e,w:s,h:a}:e)})}}),(0,k.jsx)(x.Muted,{size:12,testID:"arrange-help",children:(0,f.touchFirst)()?"Tap a table to select it, then drag it or use Move and Size below \xb7 the gold dot resizes \xb7 swipe the empty floor or the page to scroll \xb7 "+(Y?`tables snap to a ${Z} grid`:'snap to grid is off'):`Drag to move \xb7 the gold dot resizes \xb7 ${Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off'} \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes`})]}),t=(0,k.jsx)(k.Fragment,{children:pe?(0,k.jsx)(H,{t:pe,plan:F,patch:e=>me(pe.id,e),rotate:()=>Te('table',pe.id),remove:()=>fe(pe.id),duplicate:()=>{const e=$(F),t={...pe,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===pe.areaId),[t],(F.fixtures??[]).filter(e=>e.areaId===pe.areaId));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id}),de(`${(0,o.tableNumbers)(e)} added`)},join:()=>te(pe.id),split:e=>E({...F,joins:F.joins.filter(t=>t.id!==e)}),moveArea:e=>{const[t]=(0,b.placeNew)(F.tables.filter(t=>t.areaId===e),[{...pe,areaId:e,sectionId:P(F,e)}],(F.fixtures??[]).filter(t=>t.areaId===e));E({...F,tables:F.tables.map(e=>e.id===pe.id?t:e)}),X(e)},onDone:()=>J(null),toast:de,nudge:(e,t)=>Ce('table',pe.id,e*Z,t*Z,!0),grow:(e,t)=>{const s=Math.max(j.MIN_TABLE,pe.w+e*Z),a=Math.max(j.MIN_TABLE,pe.h+t*Z);if('round'===pe.shape){const e=Math.max(s,a);me(pe.id,{w:e,h:e,x:pe.x,y:pe.y})}else me(pe.id,{w:s,h:a,shape:s===a?'square':'rect',x:pe.x,y:pe.y})}}):xe?(0,k.jsxs)(h.default,{style:{gap:10},children:[(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===xe.kind)?.label}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>J(null)})]}),(0,k.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length. Or use Move and Size."}),(0,k.jsx)(U,{name:b.FIXTURES.find(e=>e.id===xe.kind)?.label??'fixture',w:xe.w,h:xe.h,nudge:(e,t)=>Ce('fixture',xe.id,e*Z,t*Z,!0),grow:(e,t)=>E({...F,fixtures:(F.fixtures??[]).map(s=>s.id===xe.id?{...s,w:Math.max(j.MIN_FIXTURE,s.w+e*Z),h:Math.max(j.MIN_FIXTURE,s.h+t*Z)}:s)})}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(x.Chip,{label:e.label,selected:xe.kind===e.id,onPress:()=>E({...F,fixtures:(F.fixtures??[]).map(t=>t.id===xe.id?{...t,kind:e.id}:t)})},e.id))}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>Te('fixture',xe.id)}),(0,k.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{E({...F,fixtures:(F.fixtures??[]).filter(e=>e.id!==xe.id)}),J(null)}})]}):(0,k.jsxs)(h.default,{style:{gap:12},children:[(0,k.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",F.areas.find(e=>e.id===G)?.name??'']}),(0,k.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,k.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=$(F),t=(0,b.newTable)(e,G,4,P(F,G)),[s]=(0,b.placeNew)(F.tables.filter(e=>e.areaId===G),[t],(F.fixtures??[]).filter(e=>e.areaId===G));E({...F,tables:[...F.tables,s]}),J({kind:'table',id:s.id})}}),(0,k.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,k.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,k.jsx)(x.Chip,{label:e.label,onPress:()=>je(e.id)})},e.id))}),(0,k.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>ye(G)}),(0,k.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>we(G)}),(0,k.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:Q}),(0,k.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:F.areas.map(e=>{const t=(0,b.planCounts)(F,e.id);return(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(x.T,{size:14,children:[e.name,(0,T.areaMarks)(e)]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[t.tables," tables \xb7 ",t.seats," seats"]})]},e.id)})})]})});return he?(0,k.jsxs)(h.default,{style:{flex:1,flexDirection:'row'},children:[(0,k.jsx)(h.default,{style:{flex:1,padding:10,gap:8},children:e}),(0,k.jsx)(u.default,{style:{width:330,flexGrow:0,flexShrink:0,flexBasis:330,borderLeftWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:t})]}):(0,k.jsxs)(u.default,{testID:"arrange-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:32},keyboardShouldPersistTaps:"handled",children:[(0,k.jsx)(h.default,{style:{padding:10,gap:8},children:e}),(0,k.jsx)(h.default,{style:{padding:14,gap:12,borderTopWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:t})]})})():null]}),se?(0,k.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,k.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,k.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:se.title}),(0,k.jsx)(s.GoldClose,{onPress:()=>ae(null),label:"Close",testID:"designer-confirm-close"})]}),(0,k.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:se.body}),(0,k.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ae(null)}),(0,k.jsx)(x.Button,{kind:se.danger?'danger':'primary',label:se.ok,testID:"confirm-ok",onPress:()=>{const e=se;ae(null),e.run()}})]})]})}):null,'save'===le&&re?(0,k.jsx)(S.SaveAsPlanDialog,{venueId:re,plan:z(F),onClose:()=>oe(null),onSaved:()=>oe(null),toast:de}):null,'list'===le&&re?(0,k.jsx)(S.SavedPlansDialog,{venueId:re,mode:e.mode,role:ne,isCar:v.IS_CAR,onClose:()=>oe(null),onLive:t=>{l({t:'reset',p:t}),e.onLiveChange?.(t),oe(null)},toast:de}):null]})};var t=r(_d[0]),s=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),T=r(_d[20]),S=r(_d[21]),I=r(_d[22]),v=r(_d[23]),k=r(_d[24]);const R=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,t){return'set'===t.t?{past:[...e.past,e.now].slice(-80),now:t.p,future:[]}:'undo'===t.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===t.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:t.p,future:[]}}function z(e){const t=new Set(e.tables.map(e=>e.name)),s=[...e.sections];for(const t of e.areas)s.some(e=>e.id===`s-${t.id}`)||e.tables.some(e=>e.areaId===t.id&&e.sectionId)||s.push({id:`s-${t.id}`,name:t.name,colour:'#CFA45F',server:''});return{...e,sections:s,fixtures:(e.fixtures??[]).filter(t=>e.areas.some(e=>e.id===t.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>t.has(e)))}}const $=e=>{let t=1;const s=new Set(e.tables.map(e=>e.name));for(;s.has(String(t));)t++;return String(t)},P=(e,t)=>e.tables.find(e=>e.areaId===t)?.sectionId??`s-${t}`,M=(e,t)=>(e.fixtures??[]).some(e=>e.areaId===t&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,t)=>{let s=(0,b.slug)(t),a=2;for(;e.areas.some(e=>e.id===s);)s=`${(0,b.slug)(t)}-${a++}`;return s};function B({label:e,glyph:t,onPress:a,disabled:l}){return(0,k.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===t?(0,k.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,k.jsx)(s.GoldX,{size:14}),(0,k.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,k.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[t,(0,k.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:t,onPick:s}){return(0,k.jsx)(u.default,{testID:"arrange-area-pills",horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0,flexShrink:0,minHeight:48},contentContainerStyle:{gap:6,paddingVertical:2,paddingRight:12,alignItems:'center'},children:e.areas.map(a=>{const l=a.id===t,o=(0,b.planCounts)(e,a.id);return(0,k.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>s(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,k.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,T.areaMarks)(a)," ",(0,k.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function N({plan:e,set:t,confirm:s,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(s,a)=>t({...e,areas:e.areas.map(e=>e.id===s?{...e,...a}:e)}),w=(s,a)=>{const l=[...e.areas],o=s+a;o<0||o>=l.length||([l[s],l[o]]=[l[o],l[s]],t({...e,areas:l}))},C=()=>{const s=f.trim();if(!s)return;if(e.areas.some(e=>e.name.toLowerCase()===s.toLowerCase()))return void c(`There's already an area called ${s}`);const a=A(e,s);t({...e,areas:[...e.areas,{id:a,name:s,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:s,colour:'#CFA45F',server:''}]}),j('')};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,k.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,k.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(E,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,k.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,k.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,k.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,k.jsx)(x.Row,{gap:8,children:(0,k.jsx)(E,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),F.map(s=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===s;return(0,k.jsx)(d.default,{testID:`area-colour-${a.id}-${s.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${s}`,onPress:()=>t({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:s}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:s}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:s,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},s)})]}),(()=>{const t=e.tables.filter(e=>e.areaId===a.id).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0})),s=a.best??[];return t.length?(0,k.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.map(e=>(0,k.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:s.includes(e.name),onPress:()=>y(a.id,{best:s.includes(e.name)?s.filter(t=>t!==e.name):[...s,e.name]})},e.id))}),(0,k.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,k.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,k.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,k.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>s({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>t({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,k.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,k.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,k.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,k.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,k.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,k.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>s({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{t(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,k.jsx)(x.T,{weight:"semibold",children:e.name}),(0,k.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const F=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function E({value:e,onCommit:t,label:s="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,k.jsx)(a.TextInput,{accessibilityLabel:s,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>t(o.trim()),onSubmitEditing:()=>t(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function W({plan:e,set:t,area:s,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[T,S]=(0,i.useState)(4),[I,v]=(0,i.useState)(''),[R,D]=(0,i.useState)(!0),z=(0,i.useMemo)(()=>(0,b.parseTableList)(I),[I]),P=e.tables.filter(e=>e.areaId===s).sort(b.byNumber),M=$(e),A=e.areas.find(e=>e.id===s),N=(e,t)=>{const s=(0,b.sizeFor)(t),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:t,minSeats:Math.min(e.minSeats,t),...l?{}:'round'===e.shape?{w:s.h,h:s.h}:{w:s.w,h:s.h,shape:s.shape}})};return(0,k.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,k.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,k.jsx)(L,{plan:e,area:s,onPick:l}),(0,k.jsxs)(x.Muted,{children:[A?`${A.name}${A.dogs?' \xb7 dogs allowed':''}${A.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,k.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:P.length?P.map((e,t)=>(0,k.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:t?1:0,borderColor:p.colours.border},children:[(0,k.jsxs)(h.default,{style:{width:92},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,k.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,k.jsx)(h.default,{style:{flex:1},children:(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:t=>N(e,t)})}),(0,k.jsx)(x.Muted,{children:"seats"}),(0,k.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,k.jsx)(h.default,{style:{padding:16},children:(0,k.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,k.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,k.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,k.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",A?.name]}),(0,k.jsxs)(x.Row,{gap:10,children:[(0,k.jsxs)(h.default,{style:{width:120},children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,k.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:M,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,k.jsxs)(h.default,{children:[(0,k.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,k.jsx)(x.Stepper,{value:T,min:1,max:20,label:"seats",onChange:S})]})]}),(0,k.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||M)}`,testID:"add-table",onPress:()=>{n([{name:(w||M).toUpperCase(),seats:T}],!1)&&C('')}})]}),(0,k.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,k.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,k.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,k.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:I,onChangeText:v,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),I.trim()?(0,k.jsxs)(x.T,{size:14,colour:z.items.length?p.colours.ok:p.colours.amber,children:["Found ",z.items.length," table",1===z.items.length?'':'s'," \xb7 ",z.items.reduce((e,t)=>e+t.seats,0)," seats",z.skipped.length?` \xb7 couldn't read: ${z.skipped.slice(0,2).join('; ')}`:'']}):null,(0,k.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:R,onChange:D}),(0,k.jsx)(x.Button,{label:z.items.length?`Add ${z.items.length} tables`:'Add tables',testID:"paste-add",disabled:!z.items.length,onPress:()=>{n(z.items,R)&&v('')}})]})]})]})}function H({t:e,plan:t,patch:s,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w,nudge:C,grow:T}){const[S,I]=(0,i.useState)(e.name);(0,i.useEffect)(()=>I(e.name),[e.id,e.name]);const v=t.joins.find(t=>t.tables.includes(e.name)),R=()=>{const a=S.trim().toUpperCase();if(a&&a!==e.name)return t.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void I(e.name)):void s({name:a})};return(0,k.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,k.jsx)(l.TableNumberWarning,{plan:t}),(0,k.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),C&&T?(0,k.jsx)(U,{name:`table ${(0,o.tableNumbers)((0,b.tableLabel)(e))}`,w:e.w,h:e.h,nudge:C,grow:T}):null,(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,k.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:S,onChangeText:I,onBlur:R,onSubmitEditing:R,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,k.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:t=>s({maxSeats:t,minSeats:Math.min(e.minSeats,t)})})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,k.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>s({minSeats:e})})]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'square',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const t=Math.max(e.w,e.h);s({shape:'round',w:t,h:t})}}),(0,k.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const t=(0,b.sizeFor)(Math.max(5,e.maxSeats));s({shape:'rect',w:e.h>e.w?e.w:t.w,h:e.h>e.w?t.w:t.h})}}),(0,k.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const t=(0,b.sizeFor)(e.maxSeats);s({shape:t.shape,w:t.w,h:t.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,k.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),v?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsxs)(x.T,{size:14,children:["Joined with ",v.tables.filter(t=>t!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,k.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(v.tables.join('+'))})]}),(0,k.jsxs)(x.Row,{gap:8,children:[(0,k.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,k.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(v.id),style:{flex:1}})]})]}):(0,k.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,k.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>s({online:e})}),t.areas.length>1?(0,k.jsxs)(h.default,{style:{gap:6},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,k.jsx)(x.Row,{gap:6,wrap:!0,children:t.areas.map(t=>(0,k.jsx)(x.Chip,{label:t.name,selected:t.id===e.areaId,onPress:()=>t.id!==e.areaId&&j(t.id)},t.id))})]}):null,(0,k.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}function U({name:e,w:t,h:s,nudge:a,grow:l}){const o=(e,t,s,a)=>(0,k.jsx)(d.default,{testID:`pad-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:a,style:({pressed:e})=>({minWidth:48,minHeight:44,paddingHorizontal:10,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:e?.7:1}),children:(0,k.jsx)(x.T,{size:16,weight:"bold",colour:p.colours.gold,children:t})},e);return(0,k.jsxs)(h.default,{testID:"move-size-pad",style:{gap:8},children:[(0,k.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move"}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('left','\u2190',`Move ${e} left`,()=>a(-1,0)),o('up','\u2191',`Move ${e} up`,()=>a(0,-1)),o('down','\u2193',`Move ${e} down`,()=>a(0,1)),o('right','\u2192',`Move ${e} right`,()=>a(1,0))]}),(0,k.jsxs)(x.T,{size:14,colour:p.colours.muted,children:["Size \xb7 ",t," \xd7 ",s]}),(0,k.jsxs)(x.Row,{gap:6,wrap:!0,children:[o('narrower','\u2212 W',`Make ${e} narrower`,()=>l(-1,0)),o('wider','+ W',`Make ${e} wider`,()=>l(1,0)),o('shorter','\u2212 H',`Make ${e} shorter`,()=>l(0,-1)),o('taller','+ H',`Make ${e} taller`,()=>l(0,1))]})]})}},1360,[813,779,812,1094,843,1104,17,219,385,278,409,85,842,804,777,1361,1363,1362,998,876,1108,1364,899,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,"touchFirst",{enumerable:!0,get:function(){return b.touchFirst}}),_e.DesignerCanvas=function({plan:e,areaId:p,sel:x,onSelect:y,onMove:v,onResize:w,snapOn:L,grid:j=l.GRID,joinFrom:z,fitWidth:C=!1}){const[I,S]=(0,n.useState)({w:0,h:0}),M=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*M,k=e.tables.filter(e=>e.areaId===p),E=(e.fixtures??[]).filter(e=>e.areaId===p),[A,F]=(0,n.useState)(null),_=[...k,...E].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),$=e=>k.some(t=>t.id===e),N=(t,n,r,i)=>(0,h.resizeBox)({...t,round:$(t.id)&&'round'===k.find(e=>e.id===t.id)?.shape},n,r,{snap:L&&!i,grid:j,min:$(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:$(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),D=(0,n.useRef)(null),W=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,_,{grid:(0,h.snapStep)(j),snap:L,free:n});let P=[],T=[];const H=(0,n.useRef)(null),B=(0,n.useRef)(0),O=(0,b.touchFirst)(),X=new Set;for(const e of k)for(const t of k)e.id!==t.id&&e.xt.x&&e.yt.y&&X.add(e.id);const Y=e=>{if(A?.id!==e.id||!M)return e;const t=A.dx/M,o=A.dy/M;if('move'===A.kind){const n=W(e,t,o,A.free);return P=n.guides,T=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...N(e,t,o,A.free)}},G=(e,t)=>{return!O||'resize'===t||(o=e.id,x?.id===o);var o},K=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>G(t,o),onResponderTerminationRequest:()=>!H.current?.armed,onResponderGrant:e=>{H.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1,armed:G(t,o)}},onResponderMove:n=>{const r=H.current;if(!r||!r.armed)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,x&&x.id===t.id||y({kind:e,id:t.id}),D.current={id:t.id,dx:i,dy:s,free:g(n)},F({id:t.id,kind:o,dx:i,dy:s,free:g(n)}))},onResponderRelease:n=>{const r=H.current;H.current=null,B.current=Date.now();const i=D.current&&D.current.id===t.id?D.current:null;if(D.current=null,F(null),!r||!r.moved||!M)return void('move'===o&&y({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/M,u=l/M,c=i?i.free:g(n);if('move'===o){const o=W(t,a,u,c);v(e,t.id,o.x,o.y)}else{const o=N(t,a,u,c);w(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{H.current=null,D.current=null,F(null)},...'move'===o?{onClick:()=>{Date.now()-B.current<700||y({kind:e,id:t.id})}}:null}),U=(e,t)=>G(e,t)?'none':'pan-x pan-y',V=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...K(e,o,'resize'),style:{position:'absolute',left:Math.max(0,Math.min(R(t.x+t.w)-22,R(l.PLAN_W)-44)),top:Math.max(0,Math.min(R(t.y+t.h)-22,R(l.PLAN_H)-44)),width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:U(o,'resize')},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),q=j,J=4*j,Q=k.map(e=>({t0:e,t:Y(e)})),Z=E.map(e=>({f0:e,f:Y(e)})),ee=(()=>{if('resize'!==A?.kind||!M)return;const e=k.find(e=>e.id===A.id);return e?N(e,A.dx/M,A.dy/M,A.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:C?{alignSelf:'stretch',height:I.w?Math.round(I.w*l.PLAN_H/l.PLAN_W):240}:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>S({w:e.nativeEvent.layout.width,h:C?Math.round(e.nativeEvent.layout.width*l.PLAN_H/l.PLAN_W):e.nativeEvent.layout.height}),children:M?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>y(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*q),top:0,bottom:0,width:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/q-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*q),left:0,right:0,height:1,backgroundColor:(t+1)*q%J===0?'#2A251C':'#17150F'}},`h${t}`)),Z.map(({f0:e,f:t})=>{const o='fixture'===x?.kind&&x.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...K('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:U(e,'move')}}),o?V('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=k.filter(t=>e.tables.includes(t.name)).map(Y);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),Q.map(({t0:e,t:n})=>{const i='table'===x?.kind&&x.id===n.id,h=z===n.id,b=A?.id===n.id,p=(0,l.tableLabel)(n),g=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityHint:i?"Selected. Use the Move and Size buttons below the plan":"Double tap to select, then move it with the buttons below the plan",accessibilityState:{selected:i},"aria-selected":i,accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${X.has(n.id)?', overlapping another table':''}${i?', selected: use the Move and Size buttons below the plan':', double tap to select'}`,...K('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||ee===n.id?3:2,borderStyle:ee===n.id?'dashed':'solid',borderColor:X.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:ee===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:U(e,'move'),shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:g,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*g),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?V('table',n,e):null]},n.id)}),A&&!A.free?P.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,A&&!A.free?T.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===A?.kind?(()=>{const e=[...k,...E].find(e=>e.id===A.id);if(!e||!M)return null;const o=N(e,A.dx/M,A.dy/M,A.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,A?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===k.length&&0===E.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]);let p=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{p=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{p=!1})}const g=e=>p||!!e.nativeEvent?.altKey},1361,[813,843,17,1362,85,842,804,777,1109,1363,1110,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1362,[842]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1363,[1362,842]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1364,[17,368,278,85,842,982,1365,804,779,812,777,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=c,_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const u=(0,e.findSavedPlanByName)(await c(a),o.name),p=(0,e.namedPlanWrite)(u,{venueId:a,name:o.name,plan:t,updatedBy:s()}),m=(0,n.getSupabase)().from('table_plans'),f='id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures',{data:y,error:_}='update'===p.kind?await m.update(p.values).eq('id',p.id).is('deleted_at',null).select(f).single():await m.insert(p.values).select(f).single();if(_)throw _;return l(y)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return u(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:u(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}async function c(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))}function u(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1365,[982,993,856,928,899]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1366,[17,219,385,85,804,777,1172,1367,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1367,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return C}}),_e.Timeline=function({plan:e,bookings:S,now:v,privacy:D,onOpen:I,turnBase:E,t0:z,t1:$,height:L,pauses:R,blockedTables:_,hideNow:O,isToday:W,compact:N=!1,fit:B=!1}){const A=(0,o.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),F=S.filter(e=>!['cancelled','noshow','finished'].includes(e.status)),[P,H]=(0,o.useState)(0),Y=B&&!F.some(e=>!e.table)?A.filter(e=>'__none'!==e.key):A,V=B&&P>0?Math.max(C,Math.min(M,Math.floor(P/Math.max(1,Y.length)))):M,U=V<44,G=(0,o.useMemo)(()=>(0,u.clashes)(F,E),[F,E]),X=Math.max(1,Math.ceil(($.getTime()-z.getTime())/9e5)),[q,J]=(0,o.useState)(0),K=Math.max(30,q-T-2),Q=Math.min(X,Math.max(1,Math.floor(K/k))),Z=q>0?Math.max(k,Math.floor(K/Q*100)/100):k,[ee,te]=(0,o.useState)(0),le=Math.max(0,X-Q),ie=Math.max(0,Math.min(le,ee)),oe=(0,f.addMins)(z,15*ie),ne=(0,f.addMins)(oe,15*Q),re=e=>(e.getTime()-oe.getTime())/9e5*Z,[se,ae]=(0,o.useState)(null),de=(0,o.useRef)(null),ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{q<=0||ce.current||(ce.current=!0,te((0,h.timelineNowScrollOffset)({now:v,t0:z,t1:$,slots:Q,lastOffset:le,hideNow:O,isToday:W})))},[z.getTime(),$.getTime(),Q,le,O,W,q]);const[ue,he]=(0,o.useState)(''),[be,me]=(0,o.useState)(null),fe=(0,o.useRef)(null);fe.current=be,(0,o.useEffect)(()=>{if(!be)return;const e=setTimeout(()=>me(null),a.ARM_MS);return()=>clearTimeout(e)},[be]);const ge=be?F.find(e=>e.id===be.id):void 0,pe=(0,o.useRef)(0),xe=(t,l)=>({onClick:()=>{if(Date.now()-pe.current<700)return;const e=(0,a.releaseOn)(fe.current,t.id,!1,Date.now());if(me(e.arm),he(''),'select'===e.action)try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(fe.current,t.id,Date.now()),onResponderGrant:e=>{de.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!de.current||!(0,a.isArmed)(fe.current,t.id,Date.now()))return;const i=e.nativeEvent.pageX-de.current.x,o=e.nativeEvent.pageY-de.current.y;(Math.abs(o)>=6||Math.abs(i)>=6)&&ae({id:t.id,row:l,dy:o})},onResponderRelease:o=>{const r=de.current;de.current=null,ae(null),pe.current=Date.now();const s=o.nativeEvent.pageX-(r?.x??0),c=o.nativeEvent.pageY-(r?.y??0),h=(0,a.releaseOn)(fe.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(me(h.arm),'select'===h.action){he('');try{n.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===h.action)return void he('');if('none'===h.action)return;he('');const b=Y.findIndex(e=>e.key===l),p=Math.max(0,Math.min(Y.length-1,b+Math.round(c/V))),x=(0,g.dragTables)(t.table,l,Y[p].key);if(!x||(0,i.guardBookingChange)(he,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,g.overCapacityAsk)(x.split('+'),(0,g.seatsOf)(e,x.split('+')).total,t.partySize),o=`${(0,j.privName)(t,D)} \u2192 ${(0,g.tablesWords)(x.split('+'))}, still ${(0,f.hm)((0,u.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;he(`Saving ${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}\u2026`),(0,i.reportBookingSave)(t.id,o,`${(0,g.tablesWords)(x.split('+'))} for ${(0,j.privName)(t,D)}`,he)}else Math.abs(s)>=6&&Math.abs(c)=600||ue?(0,w.jsx)(s.default,{style:{flex:q>=600?1:void 0,flexBasis:q>=600?void 0:'100%',minWidth:0},children:(0,w.jsx)(y.T,{size:13,center:q<600,colour:x.colours.muted,numberOfLines:q>=600?1:2,testID:"timeline-hint",children:ue||a.SELECT_HINT})}):null,R?.length?(0,w.jsxs)(y.Row,{gap:4,children:[(0,w.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:13,children:"Blocked"})]}):null,(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.goldLight,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))})}),(0,w.jsx)(s.default,{style:{flexShrink:0},children:(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[N?(0,w.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,w.jsx)(s.default,{style:{alignSelf:'center'},children:(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'})}),(0,w.jsx)(y.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ue?(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{center:!0,size:14,colour:x.colours.goldLight,children:ue})}):null]}):(0,w.jsxs)(y.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(y.Row,{gap:8,children:[(0,w.jsx)(y.Badge,{kind:G.size?'red':'ok',label:G.size?`${G.size} bookings clash`:'No clashes'}),(0,w.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,w.jsx)(y.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,w.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${G.size}`,children:(0,w.jsx)(y.T,{size:13,colour:x.colours.goldLight,children:ue})})]}),(0,w.jsxs)(y.T,{center:!0,testID:"timeline-window",children:[(0,f.hm)(oe)," to ",(0,f.hm)(ne)]}),X>Q?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===ie,onPress:()=>te(Math.max(0,ie-Q))}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:ie>=le,onPress:()=>te(Math.min(le,ie+Q))})]}):null,R?.length?(0,w.jsxs)(y.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,w.jsx)(y.T,{size:14,children:"Blocked"})]}):null]}),(0,w.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-q)>1&&J(t)},style:{flex:L?void 0:1,height:L,flexShrink:N?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:x.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,w.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:x.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,w.jsx)(s.default,{testID:"timeline-table-head",style:{width:T,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:(0,w.jsx)(y.T,{size:13,weight:"semibold",colour:x.colours.goldLight,children:"Table"})}),(0,w.jsxs)(s.default,{style:{width:Q*Z,flexShrink:0},children:[Array.from({length:Math.ceil(Q/4)},(e,t)=>(0,w.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*Z,top:26,bottom:0,width:1,backgroundColor:x.colours.border}},t)),Array.from({length:Math.ceil(Q/4)},(e,t)=>{const l=4*t*Z,i=Math.max(0,Math.min(Q*Z-56,l-28));return(0,w.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:i,width:56,top:4,height:22,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,numberOfLines:1,children:(0,f.hm)((0,f.addMins)(oe,60*t))})},`l${t}`)})]})]}),(0,w.jsxs)(r.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-P)>1&&H(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,w.jsx)(s.default,{style:{width:T,borderRightWidth:1,borderColor:x.colours.border,backgroundColor:x.colours.surface},children:Y.map((e,t,l)=>(0,w.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:V,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:x.colours.gold},children:U?(0,w.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(y.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,w.jsx)(y.T,{size:10,colour:x.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,w.jsx)(s.default,{style:{width:Q*Z,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!fe.current,onResponderRelease:()=>{me(null),he('')},children:(0,w.jsxs)(s.default,{style:{width:Q*Z},children:[(R??[]).map((e,t)=>{const l=Math.max(0,re(e.from)),i=Math.min(Q*Z,re(e.to));return i<=l?null:(0,w.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,f.hm)(e.from)} to ${(0,f.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:i-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),Y.map((e,i,o)=>{return(0,w.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:V,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:i>0&&o[i-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(Q/4)},(e,l)=>(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*Z,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),_?.includes(e.key)?(0,w.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,w.jsx)(y.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(n=e.key,F.filter(e=>('__none'===n?!e.table:(0,c.tablesOf)(e.table).includes(n))&&(0,u.startOf)(e)oe)).map(t=>{const i=se?.id===t.id&&se.row===e.key?se:null,o=re((0,u.startOf)(t)),n=Math.max(0,Math.min(Q*Z-44,o)),r=Math.min(Q*Z,re((0,f.addMins)((0,u.startOf)(t),(0,u.durOf)(t,E)))),d=Math.min(Q*Z-n,Math.max(44,r-Math.max(0,o))),c=G.has(t.id),h=be?.id===t.id;return(0,w.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,j.privName)(t,D)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,f.hm)((0,u.startOf)(t))}, ${(0,u.durOf)(t,E)} min${c?', clash':''}${(0,b.depositView)(t,!0)?`, ${(0,b.depositView)(t,!0).a11y}`:''}${h?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:h},accessibilityHint:h?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:h?'1':'0'},...xe(t,e.key),style:[{position:'absolute',left:n,top:(U?2:4)+(i?i.dy:0),width:d,height:V-(U?4:8),borderRadius:8,backgroundColor:(0,p.blockColour)(t),borderWidth:h?3:c?2.5:1,borderColor:h?x.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...h?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:i?40:h?20:2,opacity:'finished'===t.status?p.FINISHED_OPACITY:1,cursor:h?'ns-resize':'pointer',touchAction:h?'none':'pan-x pan-y'},i?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,w.jsx)(y.T,{size:14,weight:"semibold",colour:(0,p.blockTextColour)(t),numberOfLines:U?1:2,style:{lineHeight:16},children:d<100?U&&d>=70?`${t.partySize} \xb7 ${(0,f.hm)((0,u.startOf)(t))}`:String(t.partySize):(0,w.jsxs)(w.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||U?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,j.privName)(t,D)," \xb7 ",t.partySize,U?' \xb7 ':'\n',(0,f.hm)((0,u.startOf)(t)),t.allergies.length?' \u26a0':'',(0,b.depositView)(t,!0)?d>=150?` \xb7 ${(0,b.depositView)(t,!0).label}`:'Deposit paid'===(0,b.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var n})]})})]}),ye.visible?(0,w.jsx)(s.default,{testID:"now-line",pointerEvents:"none",accessible:!0,accessibilityLabel:`Current time ${ye.label}`,style:{position:'absolute',left:T+Math.max(0,Math.min(Q*Z-2,ye.x)),top:0,bottom:0,width:2,backgroundColor:x.colours.gold,zIndex:50},children:(0,w.jsx)(s.default,{testID:"now-line-pill",style:{position:'absolute',top:8,left:ye.pillLeft-Math.max(0,Math.min(Q*Z-2,ye.x)),width:ye.pillWidth,height:22,backgroundColor:x.colours.gold,borderRadius:6,justifyContent:'center'},children:(0,w.jsx)(y.T,{size:10,weight:"bold",colour:x.colours.onGold,center:!0,numberOfLines:1,children:ye.label})})}):null,ge?(0,w.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,w.jsxs)(y.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:x.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,w.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,j.privName)(ge,D)} ${a.SELECTED_A11Y}`,children:(0,w.jsxs)(y.T,{size:14,weight:"semibold",colour:x.colours.gold,center:!0,children:["Selected: ",(0,j.privName)(ge,D)," \xb7 ",ge.partySize]})}),(0,w.jsx)(y.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{me(null),I(ge)}}),(0,w.jsx)(y.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{me(null),he('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]);const k=30,M=52,C=28,T=120},1368,[813,843,1095,17,264,219,278,85,1111,858,998,1076,1369,841,863,1096,1370,804,777,1371,8]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_TZ",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOW_MARKER_TICK_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOW_PILL_W",{enumerable:!0,get:function(){return o}}),e.venueHm=u,e.timelineNowVisible=l,e.timelineNowX=c,e.timelineNowMarker=function(t){const n=Math.max(0,t.slots*t.slotWidth),d=c(t.now,t.windowStart,t.slotWidth),s=l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}),m=n>0&&d>=0&&d<=n,f=s&&m,h=n>0?Math.min(o,n):o,w=Math.max(0,Math.min(Math.max(0,n-h),d-h/2));return{visible:f,x:d,label:u(t.now),pillLeft:w,pillWidth:h}},e.timelineNowScrollOffset=function(t){if(!l({now:t.now,t0:t.t0,t1:t.t1,hideNow:t.hideNow,isToday:t.isToday}))return 0;const n=Math.floor((t.now.getTime()-t.t0.getTime())/9e5)-Math.floor(t.slots/3);return Math.max(0,Math.min(t.lastOffset,n))};const t='Europe/London',n=3e4,o=42;function u(n,o=t){try{const t=n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,hourCycle:'h23',timeZone:o}).replace('.',':').match(/(\d{1,2}):(\d{2})/);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}catch{}const u=t=>String(t).padStart(2,'0');return`${u(n.getHours())}:${u(n.getMinutes())}`}function l(t){if(t.hideNow||!1===t.isToday)return!1;const n=t.now.getTime();return n>=t.t0.getTime()&&n<=t.t1.getTime()}function c(t,n,o){return(t.getTime()-n.getTime())/9e5*o}},1369,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1370,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1371,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:o,tonightCards:s,cfg:l=null}){const[a,u]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[h,f]=(0,i.useState)(''),w=(0,i.useRef)(Date.now()),v=(0,i.useRef)(!1),k=(0,i.useRef)(0);v.current=a,(0,i.useEffect)(()=>(y.useScreensaverAsleep.getState().set(a),()=>y.useScreensaverAsleep.getState().set(!1)),[a]);const E=(0,j.idleMsFor)(l,t);(0,i.useEffect)(()=>z?(0,x.keepFullscreen)():void 0,[]),(0,i.useEffect)(()=>{if(!z)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return v.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,v.current=!1,window.__ccWokeAt=n,u(!1),I.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const i=setInterval(()=>{null!==E&&!v.current&&!D.current&&Date.now()-w.current>=E&&(v.current=!0,u(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(i)}},[E]);const I=(0,i.useRef)(n);I.current=n;const D=(0,i.useRef)(c);return D.current=c,(0,i.useEffect)(()=>{if(!z)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),c?(0,S.jsx)(M,{wake:o,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),o.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(C,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[o,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!0;if(t)return(0,k.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(_.Provider,{value:o,children:(0,S.jsx)(u.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(V,{rid:e,size:n,textSize:14})})})},_e.Saver=C;var t=r(_d[0]),n=r(_d[1]),i=r(_d[2]),o=e(i),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),u=e(r(_d[7])),c=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),v=r(_d[13]),p=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),E=r(_d[20]),I=r(_d[21]),S=r(_d[22]);const z='undefined'!=typeof window;function D(e){if(!z||'undefined'==typeof document)return e;try{const{createPortal:t}=r(_d[23],"react-dom");return t(e,document.body)}catch{return e}}function L(e){const t=(0,c.default)(),[n,o]=(0,i.useState)({width:t.width,height:t.height});return(0,i.useEffect)(()=>{if(!e||!z)return void o({width:t.width,height:t.height});const n=()=>{const e=window.visualViewport,n=Math.max(1,Math.round(e?.width||window.innerWidth||t.width)),i=Math.max(1,Math.round(e?.height||window.innerHeight||t.height));o(e=>e.width===n&&e.height===i?e:{width:n,height:i})};return n(),window.addEventListener('resize',n),window.visualViewport?.addEventListener('resize',n),window.visualViewport?.addEventListener('scroll',n),()=>{window.removeEventListener('resize',n),window.visualViewport?.removeEventListener('resize',n),window.visualViewport?.removeEventListener('scroll',n)}},[e,t.width,t.height]),n}function M({wake:e,entry:t,setEntry:i,onOk:o}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);i(l),l.length===s&&((0,v.wakePinMatches)(e,l)?o():setTimeout(()=>i(''),300))};return D((0,S.jsxs)(u.default,{testID:"wake-pin",style:{position:z?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(w.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(w.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(u.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(w.T,{size:26,colour:d.colours.gold,children:e})},e))})]}))}const T=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',P={candle:'candlelight',logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function C({rid:e,cfg:t=null,box:n}){const o=L(!n),[l,a]=(0,i.useState)(null),c=n?.width??l?.width??o.width,d=n?.height??l?.height??o.height,h=(0,i.useRef)(new s.default.Value(0)).current;(0,i.useEffect)(()=>{s.default.timing(h,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[w,v]=(0,i.useState)(()=>new Date);(0,i.useEffect)(()=>{const e=setInterval(()=>v(new Date),15e3);return()=>clearInterval(e)},[]);const p=t?t.style:'still',y=!!t&&(0,j.dimNow)(t,w),[x,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!0;if(t?.logo)return(0,k.saverPhotoUrl)(t.logo).then(t=>{e&&b(t)}),()=>{e=!1};b(null)},[t?.logo]);const E=(0,S.jsx)(_.Provider,{value:x,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?P[t.style]:'logo'}${y?', dimmed for the night':''}. Touch anywhere to wake.`,onLayout:n?void 0:e=>{const{width:t,height:n}=e.nativeEvent.layout;t>=1&&n>=1&&a(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},style:{position:n?'relative':z?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?c:void 0,height:n?d:void 0,zIndex:n?0:1e5,backgroundColor:T(e),opacity:h,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['candle'===p?(0,S.jsx)(f.CandleSaver,{width:c,height:d,logo:t=>(0,S.jsx)(V,{rid:e,size:t})}):'logo'===p?(0,S.jsx)(N,{rid:e,width:c,height:d}):'clock'===p?(0,S.jsx)(R,{rid:e,now:w,width:c,height:d}):'covers'===p?(0,S.jsx)($,{rid:e,now:w,width:c,height:d}):'photos'===p?(0,S.jsx)(O,{rid:e,paths:t?.photos??[],width:c,height:d}):'black'===p?(0,S.jsx)(u.default,{testID:"saver-black"}):(0,S.jsx)(A,{rid:e,width:c,height:d}),y?(0,S.jsx)(u.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})});return n?E:D(E)}const _=o.default.createContext(null);function V({rid:e,size:t,textSize:n}){const i=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??i.logo,a=o.default.useContext(_);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${i.name} logo`}):(0,S.jsx)(w.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:i.name})}function A({rid:e,width:t,height:n}){return(0,S.jsx)(u.default,{testID:"saver-still",children:(0,S.jsx)(V,{rid:e,size:.5*Math.min(t,n)})})}function N({rid:e,width:t,height:n}){const o=.34*Math.min(t,n),l=(0,i.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,u]=(0,i.useState)({w:o,h:o}),c=Math.max(o,a.w),d=Math.max(o,a.h);return(0,i.useEffect)(()=>{const e=Math.max(0,(t-c)/2-12),i=Math.max(0,(n-d)/2-12),o=[{x:-e,y:.6*-i},{x:.7*e,y:-i},{x:e,y:.5*i},{x:.4*-e,y:i},{x:0,y:0}],a=s.default.loop(s.default.sequence(o.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,c,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&u({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(V,{rid:e,size:o})})}function R({rid:e,now:t,width:n,height:i}){const o=Math.min(.22*n,.32*i),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(u.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*o},children:[(0,S.jsx)(V,{rid:e,size:.7*o}),(0,S.jsx)(w.T,{size:o,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*o},children:s}),(0,S.jsx)(w.T,{size:.24*o,style:{textAlign:'center'},children:l})]})}function $({rid:e,now:t,width:n,height:i}){const o=(0,E.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=o.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),c=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),f=Math.min(n/12,i/9);return(0,S.jsxs)(u.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*f},children:[(0,S.jsx)(V,{rid:e,size:2*f}),(0,S.jsx)(w.T,{size:.5*f,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(u.default,{style:{flexDirection:'row',gap:1.4*f,justifyContent:'center'},children:[(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:c}),(0,S.jsx)(w.T,{size:.42*f,children:1===c?'cover':'covers'})]}),(0,S.jsxs)(u.default,{style:{alignItems:'center'},children:[(0,S.jsx)(w.T,{size:1.6*f,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(w.T,{size:.42*f,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(w.T,{size:.4*f,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(w.T,{size:.4*f,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function O({rid:e,paths:t,width:n,height:o}){const[l,a]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),h=(0,i.useRef)(new s.default.Value(1)).current;return(0,i.useEffect)(()=>{let e=!0;return Promise.all(t.map(k.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,i.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[c%l.length]},style:{width:n,height:o,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${c%l.length+1} of ${l.length}`}):(0,S.jsx)(u.default,{testID:"saver-photos-empty",children:(0,S.jsx)(V,{rid:e,size:.4*Math.min(n,o)})})}},1372,[805,813,17,266,319,219,385,85,409,804,857,1373,777,999,916,1346,1375,880,1376,1377,858,863,8,260]); +__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,"CANDLE_SPEED",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"candleTime",{enumerable:!0,get:function(){return c}}),_e.CandleSaver=function({width:e,height:u,logo:p}){const b=(0,t.useRef)(null),w=(0,t.useRef)(null),x=(0,t.useRef)(null),y=(0,t.useRef)(null),v=Math.round((0,l.logoSize)(e,u));(0,t.useEffect)(()=>{if(!f||!b.current)return;let e=null,t=0,n=0;const o=performance.now();try{if(e=(0,l.create)({canvas:b.current,canvasFront:w.current,logoEl:x.current,glowEl:y.current,drawLogoOnCanvas:!1,reducedMotion:h(),fps:30}),e.setTime(0),!h()){const l=s=>{s-n>=33.333333333333336&&!document.hidden&&(n=s,e?.setTime(c((s-o)/1e3))),t=requestAnimationFrame(l)};t=requestAnimationFrame(l)}}catch{}return()=>{t&&cancelAnimationFrame(t),e?.destroy()}},[e,u]);const E={position:'absolute',left:'16.5%',top:'16.5%',width:'67%',height:'67%',borderRadius:9999,backgroundColor:'#050506',...f?{boxShadow:'0 0 36px 18px rgba(0,0,0,.72), 0 0 80px 28px rgba(0,0,0,.45)'}:{}},j={position:'absolute',left:0,top:0,width:'100%',height:'100%',pointerEvents:'none'};return(0,s.jsxs)(o.default,{testID:"saver-candle",style:{position:'absolute',left:0,top:0,width:e,height:u,backgroundColor:'#050403',overflow:'hidden'},accessible:!1,children:[f?n.default.createElement('canvas',{ref:b,style:{...j,zIndex:0}}):null,f?(0,s.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,zIndex:1,backgroundImage:'radial-gradient(ellipse at 50% 48%, transparent 42%, rgba(5,4,3,.3) 80%, rgba(5,4,3,.62) 100%)'}}):null,(0,s.jsxs)(o.default,{ref:x,pointerEvents:"none",style:f?{position:'absolute',left:0,top:0,zIndex:2,width:v,height:v}:{position:'absolute',left:(e-v)/2,top:(u-v)/2,width:v,height:v},children:[f?(0,s.jsx)(o.default,{ref:y,style:{position:'absolute',left:'50%',top:'42%',width:'118%',height:'118%',borderRadius:9999,transform:[{translateX:'-50%'},{translateY:'-50%'}],backgroundImage:'radial-gradient(circle, rgba(255,200,110,.26) 0%, rgba(200,120,40,.08) 42%, transparent 68%)',filter:'blur(10px)'}}):null,(0,s.jsx)(o.default,{style:E}),(0,s.jsx)(o.default,{style:{width:v,height:v,alignItems:'center',justifyContent:'center'},children:p(v)})]}),f?n.default.createElement('canvas',{ref:w,style:{...j,zIndex:3}}):null]})};var t=r(d[0]),n=e(t);r(d[1]);var o=e(r(d[2])),l=r(d[3]),s=r(d[4]);const u=.5,c=e=>e*u,f='undefined'!=typeof document,h=()=>f&&'undefined'!=typeof window&&!!window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches},1373,[17,219,85,1374,8]); +__d(function(_g,_r,_i,_a,m,e,_d){var t,a;t='undefined'!=typeof globalThis?globalThis:this,a=function(){'use strict';var t=60,a=2*Math.PI,r=20261120,n='#050403';function o(t){var a=t>>>0||1;return function(){a=1831565813+(a|=0)|0;var t=Math.imul(a^a>>>15,1|a);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}function i(t,a,r){return a+Math.floor(t()*(r-a+1))}function l(t,a,r){var n=a+2*r;return(t%n+n)%n-r}function h(t,a){if('undefined'==typeof document)throw new Error('Pass options.createCanvas(width, height) when not in a browser');var r=document.createElement('canvas');return r.width=t,r.height=a,r}function s(t,r,n,o){var i=t(r,r),l=i.getContext('2d'),h=r/2,s=Math.max(.08,.35*n),c=l.createRadialGradient(h,h,0,h,h,h),d=(o||[255,226,150])[0],f=(o||[255,226,150])[1],u=(o||[255,226,150])[2];return c.addColorStop(0,'rgba('+d+','+f+','+u+',1)'),c.addColorStop(s,'rgba('+d+','+Math.max(0,f-20)+','+Math.max(0,u-40)+',0.92)'),c.addColorStop(n,'rgba(220,150,50,0.38)'),c.addColorStop(Math.min(.92,n+.35),'rgba(160,90,20,0.08)'),c.addColorStop(1,'rgba(0,0,0,0)'),l.fillStyle=c,l.beginPath(),l.arc(h,h,h,0,a),l.fill(),i}function c(t,r){var n=t(r,r),o=n.getContext('2d'),i=r/2,l=o.createRadialGradient(i,i,0,i,i,i);return l.addColorStop(0,'rgba(255,250,230,1)'),l.addColorStop(.18,'rgba(255,220,140,0.9)'),l.addColorStop(.45,'rgba(232,180,70,0.25)'),l.addColorStop(1,'rgba(0,0,0,0)'),o.fillStyle=l,o.beginPath(),o.arc(i,i,i,0,a),o.fill(),n}function d(t,a){return Math.min(.56*t,.52*a)}function f(r,n,o,i,l){var h=Math.max(28,.04*Math.min(n,o)),s=h,c=h,d=Math.max(0,n-i-2*h),f=Math.max(0,o-l-2*h),u=r%t,p=s+(.5+.5*Math.sin(a*u/60))*d,g=c+(.5+.5*Math.sin(a*u/30-.18))*f;return{x:p,y:g,cx:p+i/2,cy:g+l/2,w:i,h:l}}function u(t,a,r,n,o,i){var l=(t-r)/(.2*o),h=(a-n)/(.22*i),s=Math.sqrt(l*l+h*h);return s>=1?1:s<.4?0:(s-.4)/.6}function p(t){return{far:[s(t,256,.55,[255,220,140]),s(t,224,.62,[255,200,110]),s(t,192,.5,[255,230,160])],mid:[s(t,128,.32,[255,230,160]),s(t,112,.38,[255,210,120]),s(t,96,.28,[255,236,180])],near:[s(t,80,.2,[255,240,190]),s(t,64,.18,[255,224,140]),s(t,48,.16,[255,236,200])],spark:c(t,16),spark2:c(t,10)}}function g(r,n,l,h){var s,c,d,f,u,p,g,w,M,b,x,y,v,S=o(h),C=[];for(s=0;s<96;s++)u=(f=0==(d=(c=Math.pow(S(),.7))<.34?0:c<.7?1:2)?l.far:1===d?l.mid:l.near)[s%f.length],p=0===d?1.1+.9*S():1===d?.9+.7*S():.8+.6*S(),w=r+2*(g=u.width*p),M=n+2*g,b=(0===d?14:1===d?26:40)*(.7+.7*S())*.55,x=Math.max(1,Math.round(b*t/M)),y=S()<.5?-1:1,v=i(S,0===d?3:4,0===d?6:8),C.push({x:S()*r,y:S()*n,z:c,layer:d,front:2===d&&S()<.35,spr:u,size:g,base:0===d?.28+.35*S():.5+.45*S(),ph:S()*a,ph2:S()*a,flickN:i(S,8,14),flickN2:i(S,14,22),rise:x*M/t,ampX:(0===d?36:1===d?54:70)*(.8+.6*S()),ampY:(0===d?16:1===d?24:32)*(.8+.6*S()),spinN:y*v,spinN2:(S()<.5?-1:1)*i(S,2,4),driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(12+10*S())*t/w)),wrapW:w,wrapH:M});C.sort(function(t,a){return t.z-a.z});var N=[];for(s=0;s<140;s++)g=5+10*S(),w=r+24,M=n+24,b=.55*(18+40*S()),x=Math.max(1,Math.round(b*t/M)),N.push({x:S()*r,y:S()*n,spr:S()<.4?l.spark2:l.spark,size:g,base:.35+.65*S(),ph:S()*a,twN:i(S,6,12),rise:x*M/t,driftK:(S()<.5?-1:1)*Math.max(1,Math.round(.55*(16+14*S())*t/w)),amp:8+18*S(),spinN:(S()<.5?-1:1)*i(S,3,6),front:S()<.2,wrapW:w,wrapH:M});return{orbs:C,sparks:N}}function w(r,n,o,i,h,s,c){for(var d,f,p,g,w,M,b,x,y,v,S=(i%t+t)%t,C=h.orbs,N=h.sparks,z=0;z=1e3/c&&(G=t,O(L())),W=requestAnimationFrame(X))}function B(){F=!0,W&&'function'==typeof cancelAnimationFrame&&cancelAnimationFrame(W),W=0}return{start:function(){u?O(0):(F=!1,I='undefined'!=typeof performance?performance.now():0,q=null,G=0,O(0),'function'==typeof requestAnimationFrame&&(W=requestAnimationFrame(X)))},stop:B,setTime:function(t){q=t,O(t)},resize:function(t,a){A=t,R=a,H(t,a),O(L())},destroy:function(){B(),E={orbs:[],sparks:[]}},render:O,renderTo:function(t,a,r,o){H(a=a||A,r=r||R);var i=(o%l+l)%l,h=d(a,r),s=f(i,a,r,h,h);return t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle=n,t.fillRect(0,0,a,r),w(t,a,r,i,E,s,!1),M(t,C,s,i),w(t,a,r,i,E,s,!0),b(t,a,r),s},setLogo:function(t){C=t},getPeriod:function(){return l},getSize:function(){return{width:P,height:T}}}},PERIOD:t,FPS:30,SEED:r,VERSION:'1.0.0',logoSize:d,logoOrigin:f}},'object'==typeof m&&m.exports?m.exports=a():t.CandleScreensaver=a()},1374,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1375,[219]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'},{id:'candle',label:'Candlelight',sub:'Warm gold candlelight drifting on a dark screen, with your logo slowly roaming'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1377,[17,831,928,899,1376]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=$,e.guestRowText=function(n,l){const p=n.partySize,b=Math.max(0,Math.min(p-1,Math.round(Number(n.children)||0))),c=`${p} ${1===p?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,h=(0,s.tablesOf)(n.table??void 0),f=h.length?`${l.tableWord?'Table ':''}${(0,t.tableNumbers)(n.table)}`:'',y=l.leftEarly?"Left early"+(f?` \xb7 ${f}`:''):l.finished?"Finished"+(f?` \xb7 ${f}`:''):l.seated?"Seated"+(f?` \xb7 ${f}`:''):f||'No table yet',w=$(n),x=h.length?`table${h.length>1?'s':''} ${u(h.map(t.plainTableNumber))}`:l.finished?'finished':'no table yet',D=!!n.dog,m=(0,o.allergyLine)(n),k=(n.tags??[]).includes('VIP')?'VIP':(n.tags??[]).includes('Regular')?'Regular':null,v=n.occasion??(n.notes?/birthday/i.test(n.notes)?'birthday':/anniversary/i.test(n.notes)?'anniversary':null:null),P=(0,d.guestChangeLine)(n),I=[n.time,l.name,m?`allergy noted: ${m}`:'','VIP'===k?'VIP':'Regular'===k?'regular':'',v??'',c,l.leftEarly?'left early':l.finished?'finished':l.seated?'seated':'',w?.spoken??'',x,D?'dog':''].filter(Boolean).join(', ')+'.'+(P?` ${P}`:'');return{time:n.time,name:l.name,people:c,deposit:w?.text??null,depositWarn:!!w?.warn,table:y,dog:D,allergy:m,vip:k,occasion:v,guestChange:P,a11y:I}};var t=r(_d[0]),n=r(_d[1]),s=r(_d[2]),o=r(_d[3]),d=r(_d[4]);const l=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,p=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,u=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function $(t){const s=(0,n.depositBadge)(t,l);if(!s)return null;const o=(0,n.wixPayStatus)(t),d=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===o||d>0&&u>d&&!s.label.startsWith('Deposit paid')){const t=d||0;return t>0&&u>t?{text:`Deposit ${l(t)} of ${l(u)} paid`,spoken:`deposit ${p(t).replace(' pounds','')} of ${p(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(s.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const $=s.label.match(/\xa3[\d.,]+/);if(s.label.startsWith('Deposit paid')){const t=/about/.test(s.label);return $?{text:`Deposit paid ${t?'about ':''}${$[0]}`,spoken:`deposit ${t?'about ':''}${$[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(s.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(s.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:$?{text:`Deposit ${$[0]} not paid`,spoken:`deposit ${$[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1378,[843,841,998,1379,1380]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1379,[845]); +__d(function(_g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestChangeOf=s,e.guestChangeLine=function(t){const n=s(t);if(!n||'cancelled'===t.status)return null;const m=[];n.from.date!==n.to.date&&m.push(o(n.from.date));n.from.time!==n.to.time&&m.push(n.from.time);n.from.partySize!==n.to.partySize&&m.push(`${n.from.partySize} ${1===n.from.partySize?'person':'people'}`);const c=u(n.at);return[`Changed by the guest${c?` at ${c}`:''}.`,m.length?`Was ${m.join(', ')}.`:'',n.needsTable?`Needs a table${n.from.table?` (was ${n.from.table})`:''}.`:'',n.needsCheck?'Needs confirming.':''].filter(Boolean).join(' ')};const t=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],o=o=>{const[u,s,m]=o.split('-').map(Number),c=new Date(Date.UTC(u,s-1,m,12));return`${t[c.getUTCDay()]} ${m} ${n[s-1]}`},u=t=>{const n=new Date(t);return Number.isNaN(n.getTime())?'':n.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};function s(t){const n=t.guestChange;return n&&'object'==typeof n&&n.from&&n.to?n:null}},1380,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1381,[17,85,780,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.GuestActionsSheet=function({rid:e,b:N,name:A,view:W,now:H,onClose:T,onDetails:E,onDone:F,otherDay:_,turnBase:O=90,onPickOnPlan:R,onEdit:U}){const[M,G]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),[J,K]=(0,n.useState)(null),[Q,V]=(0,n.useState)(!1),X=(0,$.useBookingWrite)(),[Z,ee]=(0,n.useState)(!1),[te,se]=(0,n.useState)(!1),[ae,ie]=(0,n.useState)(!1),le=(0,k.guestRowText)(N,{name:A,seated:'seated'===N.status&&!_}),ne='seated'===N.status&&!_,oe=N.table?ne?`Seated \xb7 ${(0,l.tableCardLabel)(N.table)}`:(0,l.tableCardLabel)(N.table):ne?'Seated':'No table yet',de=_?[]:(0,g.guestActions)(N,A,W,H).filter(e=>'details'!==e.id),re=(0,h.tableActions)(N,A),ce={id:'details',label:'Guest details',a11y:`Guest details, ${A}`},be=async t=>{if(!(0,a.guardBookingChange)(F,{b:N,tables:[t]}))return;const s={...N,table:t};t!==N.table&&await y.repo.bookings.update(N.id,{table:t}),await(0,u.seatBookingNow)(e,s),F(`Saving: ${A} at ${(0,g.tableWords)(t)}\u2026`),T(),(0,a.reportBookingSave)(N.id,`${A} seated at ${(0,g.tableWords)(t)}.`,`${A} at ${(0,g.tableWords)(t)}`,F)},ue=async e=>{!(0,w.needsEarlySeatConfirm)(N,H)||J?await be(e):K({go:()=>be(e)})},ye=async t=>{if('seat'===t.id&&t.table)return ue(t.table);if('pick'===t.id)return q(e=>!e);if('details'===t.id)return T(),E(N);if('finished'===t.id){if(!X.ok)return;return Q?(V(!1),'seated'===N.status?await(0,B.finishAndOfferUndo)(e,[N],A,{big:!0,table:N.table}):await(0,B.finishUnseatedAndOfferUndo)(e,N,A,{big:!0}),T()):void V(!0)}return'noshow'===t.id?(await y.repo.bookings.setStatus(N.id,'noshow'),F(`${A} marked as a no-show.`),T()):void 0},ge=Y?(0,g.freeTablesNow)(W,N.partySize,!0).slice(0,12):[];if(Z)return(0,P.jsx)(f.TablePicker,{rid:e,booking:N,name:A,turnBase:O,onClose:T,onSaved:F,onPickOnPlan:R?e=>{T(),R(N,e)}:void 0});if(te)return(0,P.jsx)(x.CancelWalkInConfirm,{rid:e,b:N,onClose:T,onDone:F});if(ae)return(0,P.jsx)(j.CancelBookingConfirm,{rid:e,b:N,name:A,onClose:T,onDone:F});const ke=[...de];return(0,P.jsxs)(b.Sheet,{visible:!0,onClose:T,title:`${N.time} \xb7 ${A}`,maxWidth:560,testID:"guest-actions",children:[(0,P.jsx)(a.BookingNotSavedLine,{b:N}),(0,P.jsx)(c.default,{accessible:!0,accessibilityLabel:le.a11y,testID:"guest-actions-summary",children:(0,P.jsxs)(b.T,{size:18,children:[le.people,le.deposit?(0,P.jsxs)(b.T,{size:18,weight:"semibold",colour:le.depositWarn?S.colours.amber:S.colours.goldLight,children:[" \xb7 ",le.deposit]}):null," \xb7 ",oe]})}),(0,P.jsx)(t.ShowNumberButton,{b:N}),J?(0,P.jsx)(v.EarlySeatConfirm,{time:N.time,onYes:()=>{const e=J.go;K(null),e()},onNo:()=>K(null)}):null,Q?(0,P.jsx)(B.FinishConfirm,{prompt:(0,I.finishConfirmPrompt)({name:A,table:N.table,seatedAt:N.seatedAt,now:H,seated:'seated'===N.status}),onNo:()=>V(!1),onYes:()=>{ye({id:'finished',label:'Finished',a11y:''})}}):null,'finished'!==N.status||_?null:(0,P.jsx)(c.default,{style:{alignItems:'center'},children:(0,P.jsx)(D.BookingUndo,{b:N,rid:e,today:(0,p.ymd)(H),who:A,allowed:X.ok})}),(0,P.jsxs)(c.default,{style:{gap:10},children:[ke.map(e=>(0,P.jsxs)(o.default.Fragment,{children:[(0,P.jsx)(b.Button,{kind:z(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:X.hint,disabled:'details'!==e.id&&!X.ok,testID:`guest-act-${e.id}`,onPress:()=>ye(e),style:L}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,P.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&Y?(0,P.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ge.length?(0,P.jsx)(b.Muted,{children:"No free tables right now."}):null,M?(0,P.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:M.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:S.colours.amber,backgroundColor:S.colours.amberBg},children:[(0,P.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:M.ask}),(0,P.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!X.ok,accessibilityHint:X.hint,onPress:()=>{const e=M.table;G(null),ue(e)},style:L}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>G(null),style:L})]}):ge.map(e=>(0,P.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,N.partySize);t?G({table:e.table,ask:t}):ue(e.table)},style:L},e.table))]}):null]},e.id)),re.map(t=>(0,P.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:X.hint,disabled:!X.ok,testID:`guest-act-${t.id}`,style:L,onPress:async()=>{if(X.ok)return'assign'===t.id?ee(!0):void((0,a.guardBookingChange)(F,{b:N,tables:[]})&&(T(),await(0,a.saveTablesReported)(e,N,[],A,0,F)))}},t.id)),!_&&(0,x.canCancelWalkIn)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${N.ref}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelwalkin",onPress:()=>se(!0),style:L}):null,(0,C.canCancelBooking)(N)?(0,P.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${A}, ${N.time}, ${N.partySize} Covers`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-cancelbooking",onPress:()=>ie(!0),style:L}):null,!U||N.walkIn||['cancelled','noshow'].includes(N.status)||_&&!(N.date>=(0,p.ymd)(H))?null:(0,P.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${A}, ${N.time}. Date, time, covers, table, anything.`,accessibilityHint:X.hint,disabled:!X.ok,testID:"guest-act-edit",onPress:()=>{T(),U(N)},style:L}),(0,P.jsx)(b.Button,{kind:"ghost",label:ce.label,accessibilityLabel:ce.a11y,testID:"guest-act-details",onPress:()=>ye(ce),style:L})]}),(0,P.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:T,style:L})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),C=r(d[16]),S=r(d[17]),$=r(d[18]),w=r(d[19]),v=r(d[20]),B=r(d[21]),D=r(d[22]),I=r(d[23]),P=r(d[24]);const L={minHeight:64},z=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1382,[1383,843,1095,998,17,85,777,1098,858,1116,1378,1096,863,1093,1117,1118,1119,804,1338,1385,1386,1115,1355,1113,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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(b.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(b.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=b.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,b.canShowNumber)(e,!y||(0,h.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show phone number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,b.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,b.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),b=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1383,[17,362,385,85,858,920,876,996,1384,856,804,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1384,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EARLY_SEAT_MINS",{enumerable:!0,get:function(){return n}}),e.needsEarlySeatConfirm=function(n,o){if(n.walkIn||!n.date||!n.time)return!1;const u=(0,t.atTime)((0,t.parseYmd)(n.date),n.time);return o.getTime()'confirmed'===e.status).map(e=>({b:e,m:(0,c.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,P.jsxs)(y.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,P.jsxs)(x.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,P.jsx)(p.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,P.jsxs)(y.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,P.jsx)(p.T,{size:13,weight:"semibold",children:e.time}),(0,P.jsxs)(p.T,{size:13,children:[(0,j.privName)(e,s)," \xb7 ",e.partySize]}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,n.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,n.tableNumbers)(e.table)}`:'no table'}),(0,P.jsx)(p.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,P.jsx)(p.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,P.jsx)(p.T,{size:12,children:C.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,P.jsxs)(p.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,P.jsxs)(p.Row,{gap:4,children:[(0,P.jsx)(y.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:C.STATUS[e].colour}}),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:C.STATUS[e].label})]},e)),(0,P.jsx)(p.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,b.useState)(20);return(0,b.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,b.useEffect)(()=>{l<=0&&s()},[l]),(0,P.jsxs)(p.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,P.jsx)(p.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,P.jsx)(p.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return L}}),_e.TableSheet=function({rid:e,name:s,view:l,plan:o,todays:h,now:x,privacy:v,turnBase:T,onClose:M,onWalkIn:L,onMove:A,onDetails:R}){const W=l[s],O=k.useFloor.getState(),[H,E]=(0,b.useState)(!1),[F,U]=(0,b.useState)(W?.note??''),[_,G]=(0,b.useState)(!1),[Y,V]=(0,b.useState)(!1),[K,q]=(0,b.useState)(!1),[J,X]=(0,b.useState)(null),[Q,Z]=(0,b.useState)(null),ee=(0,I.useBookingWrite)(),te=async(e,t)=>{(0,B.needsEarlySeatConfirm)(e,x)?X({time:e.time,go:t}):await t()};if(!W)return null;const se=W.booking,le=['seated','mains','dessert','bill'].includes(W.status);if(le&&!Y){const l=se?(0,j.privName)(se,v):'the party',a=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x)),o=a.reduce((e,t)=>e+t.partySize,0);return(0,P.jsx)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:560,testID:"seated-table-sheet",children:(0,P.jsxs)(y.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[se?(0,P.jsxs)(p.T,{size:18,center:!0,weight:"semibold",testID:"seated-sheet-who",children:[l," \xb7 ",se.partySize," ",1===se.partySize?'person':'people'," \xb7 seated ",W.seatedMins," min"]}):(0,P.jsx)(p.T,{size:18,center:!0,children:"Table order open"}),a.length>1?(0,P.jsxs)(p.T,{size:15,center:!0,colour:$.colours.goldLight,testID:"seated-sheet-parties",children:[a.length," parties seated here \xb7 ",o," people. Clear table clears all of them."]}):null,'clear'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:l,table:s,parties:a.length,seatedAt:se?.seatedAt,now:x,seated:!0}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{await(0,z.finishAndOfferUndo)(e,a.length?a:se?[se]:[],l,{big:!0,table:s}),k.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"primary",label:"Clear table",testID:"clear-table",accessibilityLabel:a.length>1?`Clear ${(0,n.tableNumbersA11y)(s)}: all ${a.length} parties have left, table needs clearing`:`Clear ${(0,n.tableNumbersA11y)(s)}: ${l} has left, table needs clearing`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&Z('clear')},style:{minHeight:72,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}),se&&!K?(0,P.jsx)(p.Button,{kind:"secondary",label:"Unseat",testID:"unseat-table",accessibilityLabel:`Unseat ${l}: ${se.walkIn?'removes the walk-in':'back to booked'}, table free again`,accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>q(!0),style:{minHeight:60,width:'100%',maxWidth:420,alignSelf:'center'}}):null,se&&K?(0,P.jsxs)(y.default,{testID:"unseat-table-confirm",accessibilityLiveRegion:"polite",style:{gap:8,width:'100%',maxWidth:420,alignItems:'center',borderWidth:1.5,borderColor:$.colours.gold,borderRadius:12,padding:10},children:[(0,P.jsxs)(p.T,{size:16,center:!0,weight:"semibold",children:["Unseat ",l,"? ",se.walkIn?'The walk-in is removed':'They go back to Booked'," and ",(0,n.tableNumbers)(s)," is free again."]}),(0,P.jsxs)(p.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{label:"Yes, unseat",testID:"unseat-table-yes",onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(se.id,(0,C.unseatStatus)(se)),(0,k.tablesOf)(se.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!1})),M())},style:{minHeight:56}}),(0,P.jsx)(p.Button,{kind:"ghost",label:"Keep seated",testID:"unseat-table-no",onPress:()=>q(!1),style:{minHeight:56}})]})]}):null,se?(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Move table",testID:"move-party",accessibilityLabel:`Move ${l} to another table`,onPress:()=>{M(),A(s)},style:{minHeight:48,alignSelf:'center'}}):null,(0,P.jsxs)(y.default,{testID:"seated-extra",style:{width:'100%',gap:10,alignItems:'center',borderTopWidth:1,borderColor:$.colours.hairline,paddingTop:10},children:[(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):null,W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se?(0,P.jsx)(S.DepositChip,{b:se,money:!0,testID:"table-sheet-deposit"}):null]}),(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:"secondary",label:"Block table",onPress:()=>{O.setLive(e,s,{blocked:!0}),M()},testID:"block-table"}),(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',testID:"table-note",onPress:()=>E(!H)}),se?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,style:{width:'100%',maxWidth:420},children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,se&&se.walkIn?(0,P.jsx)(y.default,{style:{width:'100%',maxWidth:420},children:(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0})}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null]})]})})}const ae=h.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,c.minsBetween)(x,(0,C.startOf)(e)))-Math.abs((0,c.minsBetween)(x,(0,C.startOf)(t)))),ie=e=>e.partySize<=W.table.maxSeats,ne=W.next??W.due,oe=(0,C.turnFor)(W.covers||W.table.maxSeats,T);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:M,title:`${(0,n.tableNumbers)(s)} \xb7 ${C.STATUS[W.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===W.status?(0,P.jsx)(p.Button,{kind:"primary",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${s} cleared, table free`,onPress:()=>{k.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),M()},testID:"mark-clean",style:{minHeight:64,width:'100%',maxWidth:420,alignSelf:'center',...t.look.primary(!1)}}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Badge,{kind:"neutral",label:`${W.table.minSeats}\u2013${W.table.maxSeats} seats`}),se?(0,P.jsx)(p.Badge,{kind:"gold",label:`${(0,j.privName)(se,v)} \xb7 ${se.partySize} \xb7 ${W.seatedMins}m`}):null,se?(0,P.jsx)(p.Badge,{kind:W.seatedMins>(0,C.durOf)(se,T)?'red':'neutral',label:`Turn about ${(0,C.durOf)(se,T)} min \xb7 free about ${(0,c.hm)((0,C.endOf)(se,T))} (est.)`}):(0,P.jsx)(p.Badge,{kind:"neutral",label:`Turn estimate for ${W.table.maxSeats}: about ${oe} min`}),W.next?(0,P.jsx)(p.Badge,{kind:"blue",label:`Next: ${W.next.time} ${(0,j.privName)(W.next,v)} (${W.next.partySize})`}):null,W.allergy?(0,P.jsx)(p.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,se??ne?(0,P.jsx)(S.DepositChip,{b:se??ne,money:!0,testID:"table-sheet-deposit"}):null]}),se??ne?(0,P.jsx)(r.BookingTableButton,{rid:e,booking:se??ne,turnBase:T,testID:"table-sheet-table-btn"}):null,se&&se.walkIn?(0,P.jsx)(u.CancelWalkInButton,{rid:e,b:se,big:!0}):null,se&&se.walkIn?(0,P.jsx)(u.ReinstateWalkInButton,{rid:e,b:se,today:(0,c.ymd)(new Date)}):null,J?(0,P.jsx)(D.EarlySeatConfirm,{time:J.time,onYes:()=>{const e=J.go;X(null),e()},onNo:()=>X(null)}):null,!le&&'blocked'!==W.status&&ne?(0,P.jsx)(p.Button,{label:`Seat ${(0,j.privName)(ne,v)}`,accessibilityLabel:`Seat ${(0,j.privName)(ne,v)}, ${ne.time} booking, ${ne.partySize} ${1===ne.partySize?'person':'people'}, at table ${s}`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!ee.ok||!(0,a.guardBookingChange)(void 0,{b:ne,tables:[s]}))return;const t=ne;await te(t,async()=>{await w.repo.bookings.update(t.id,{table:t.table&&(0,k.tablesOf)(t.table).includes(s)?t.table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})}}):null,!le&&'blocked'!==W.status&&ne&&(0,C.startOf)(ne)<=x?(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:['due'===Q?(0,P.jsx)(z.FinishConfirm,{prompt:(0,N.finishConfirmPrompt)({name:(0,j.privName)(ne,v),table:ne.table,seatedAt:ne.seatedAt,now:x,seated:'seated'===ne.status}),onNo:()=>Z(null),onYes:()=>{ee.ok&&(Z(null),(async()=>{'seated'===ne.status?await(0,z.finishAndOfferUndo)(e,[ne],(0,j.privName)(ne,v),{big:!0,table:ne.table}):await(0,z.finishUnseatedAndOfferUndo)(e,ne,(0,j.privName)(ne,v),{big:!0}),M()})())}}):(0,P.jsx)(p.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,j.privName)(ne,v)}, ${ne.time} booking, without seating`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:()=>{ee.ok&&Z('due')}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,j.privName)(ne,v)}, ${ne.time} booking`,accessibilityHint:ee.hint,disabled:!ee.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{ee.ok&&(await w.repo.bookings.setStatus(ne.id,'noshow'),M())}})]}):null,le||'blocked'===W.status?null:(0,P.jsxs)(p.Row,{gap:8,style:{justifyContent:'center'},children:[(0,P.jsx)(p.Button,{kind:'dirty'===W.status?'secondary':'primary',label:"Seat walk-in here",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&('dirty'===W.status&&k.useFloor.getState().setLive(e,s,{dirty:!1}),M(),L(s))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,P.jsx)(p.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:ee.hint,disabled:!ee.ok,onPress:()=>{ee.ok&&G(!_)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),_?(0,P.jsxs)(y.default,{style:{gap:6},children:[0===ae.length?(0,P.jsx)(p.Muted,{children:"No bookings left to seat today."}):null,ae.slice(0,8).map(t=>(0,P.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,j.privName)(t,v)} ${t.time}`,onPress:async()=>{(0,a.guardBookingChange)(void 0,{b:t,tables:[s]})&&await te(t,async()=>{await w.repo.bookings.update(t.id,{table:s}),await w.repo.bookings.setStatus(t.id,'seated'),(0,f.resetTableLive)(e,s),M()})},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:ie(t)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:[t.time," \xb7 ",(0,j.privName)(t,v)," \xb7 ",t.partySize,t.table?` \xb7 booked ${(0,n.tableNumbers)(t.table)}`:'',t.allergies.length?' \xb7 \u26a0':'']}),ie(t)?null:(0,P.jsxs)(p.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",W.table.maxSeats," max)"]})]},t.id))]}):null,le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(p.T,{size:14,center:!0,colour:$.colours.muted,children:"Course / status"}),(0,P.jsx)(p.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:C.STAGES.map(t=>(0,P.jsx)(p.Chip,{label:C.STAGE_LABEL[t],selected:W.status===t,onPress:()=>O.setLive(e,s,{stage:t})},t))}),(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[se?(0,P.jsx)(p.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{M(),A(s)},testID:"move-party"}):null,(0,P.jsx)(p.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{const t=(0,C.seatedPartiesAt)(s,h,(0,c.ymd)(x));for(const s of t)await w.repo.bookings.setStatus(s.id,'finished'),(0,k.tablesOf)(s.table).forEach(t=>O.setLive(e,t,{stage:void 0,dirty:!0}));O.setLive(e,s,{stage:void 0,dirty:!0}),M()}})]})]}):null,(0,P.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"secondary",label:'blocked'===W.status?'Unblock table':'Block table',onPress:()=>{O.setLive(e,s,{blocked:'blocked'!==W.status}),M()},testID:"block-table"}),'dirty'===W.status?null:(0,P.jsx)(p.Button,{kind:"ghost",label:W.note?'Edit note':'Note',onPress:()=>E(!H)}),se||ne?(0,P.jsx)(p.Button,{kind:"ghost",label:"Guest details",onPress:()=>{M(),R(se??ne)},testID:"guest-details"}):null]}),H?(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Table note",value:F,onChangeText:U,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[p.styles.input,{flex:1}]}),(0,P.jsx)(p.Button,{small:!0,label:"Save",onPress:()=>{O.setLive(e,s,{note:F.trim()||void 0}),E(!1)}})]}):null,v?(0,P.jsx)(p.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(s))?(0,P.jsxs)(p.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(s)).tables.filter(e=>e!==s).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(s)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:a,waiting:n,now:o,privacy:r,busy:u,onToast:h}){const[x,v]=(0,b.useState)(''),[S,I]=(0,b.useState)(2),B=(0,k.useFloor)(e=>e.smsLog);return(0,P.jsxs)(M,{title:`Waitlist (${n.length})`,right:(0,P.jsxs)(p.Muted,{children:["new party about ",(0,T.estimateWait)(n.length+1,t.settings.turnMins,u)," min"]}),testID:"waitlist-panel",children:[0===n.length?(0,P.jsx)(p.Muted,{children:"Nobody waiting."}):null,n.map((i,n)=>{const b=(0,C.suggestTable)(s,a,l,i.partySize,o,(0,C.turnFor)(i.partySize,t.settings.turnMins)),m=(0,T.estimateWait)(n+1,t.settings.turnMins,u),x=Math.max(0,(0,c.minsBetween)(new Date(i.joinedAt),o)),v=B.find(t=>t.rid===e&&t.text.includes(`#${i.number} `));return(0,P.jsxs)(y.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsxs)(p.T,{weight:"semibold",children:["#",i.number," ",(0,j.pv)(i.name,r)," \xb7 ",i.partySize]}),(0,P.jsxs)(p.T,{size:12,colour:x>m?$.colours.amber:$.colours.muted,children:["waited ",x,"m \xb7 quoted about ",m,"m"]})]}),b?(0,P.jsxs)(p.T,{size:12,colour:b.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",b.table," (",b.why,")"]}):(0,P.jsx)(p.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,P.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(p.Button,{small:!0,label:v||'notified'===i.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${i.number}`,onPress:()=>{k.useFloor.getState().logSms(e,o.toISOString(),`#${i.number} ${i.partySize}: Your table at ${t.name} is ready.`),w.repo.waitlist.setStatus(i.id,'notified'),h(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),b?(0,P.jsx)(p.Button,{small:!0,kind:"success",label:`Seat at ${b.table}`,onPress:async()=>{await w.repo.waitlist.setStatus(i.id,'seated'),await w.repo.bookings.seatWalkIn(e,i.partySize,b.table,`From waitlist #${i.number}`),(0,f.resetTableLive)(e,b.table),h(`Waitlist #${i.number} seated at ${b.table}`)}}):null,(0,P.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>w.repo.waitlist.setStatus(i.id,'removed')})]}),'notified'===i.status?(0,P.jsx)(p.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,c.hm)(new Date(v.at))}`:''} `}):null]},i.id)}),(0,P.jsxs)(p.Row,{gap:6,children:[(0,P.jsx)(i.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:x,onChangeText:v,style:[p.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,P.jsx)(m.default,{accessibilityLabel:"Waitlist party size",onPress:()=>I(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(p.T,{weight:"bold",colour:$.colours.gold,children:S})}),(0,P.jsx)(p.Button,{small:!0,label:"Add",disabled:x.trim().length<2,onPress:()=>{w.repo.waitlist.join(e,x.trim(),S),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:s,now:a,walkInCount:i,staffOn:n,onSummary:r}){const u=i+s.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?u/h:1,x=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,f=Array.from({length:8},(e,t)=>{const l=(0,c.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,c.addMins)(l,15),n=s.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,C.startOf)(e);return t>=l&&te+t.partySize,0);return{from:l,covers:n,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...f.map(e=>e.covers)),k=f.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,S=Math.ceil(v/16);return(0,P.jsxs)(M,{title:"Pace & kitchen",right:(0,P.jsx)(p.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,P.jsxs)(y.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${u} vs forecast ${h}`,style:{gap:4},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{size:14,children:"Covers so far"}),(0,P.jsxs)(p.T,{weight:"bold",colour:x,children:[u," ",(0,P.jsxs)(p.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,P.jsx)(y.default,{style:{height:10,borderRadius:5,backgroundColor:(0,l.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,P.jsx)(y.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:x}})}),(0,P.jsxs)(p.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,P.jsx)(p.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,P.jsx)(y.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:f.map((e,t)=>(0,P.jsxs)(y.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,P.jsx)(p.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,P.jsx)(y.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,P.jsx)(p.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,c.hm)(e.from)})]},t))}),k.map(e=>(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,c.hm)(e.from),"\u2013",(0,c.hm)((0,c.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),S>n?(0,P.jsxs)(p.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",n," on: about ",S-n," more on the floor suggested."]}):(0,P.jsxs)(p.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",n," on)."]}),(0,P.jsx)(p.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:r,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const n=t.filter(e=>['seated','finished'].includes(e.status)),o=n.reduce((e,t)=>e+t.partySize,0)+a,r=t.filter(e=>e.walkIn),u=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,c.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,k.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{children:e}),(0,P.jsx)(p.T,{weight:"semibold",children:t})]},e);return(0,P.jsxs)(p.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(o)),h('Bookings seated',`${n.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${r.length} parties \xb7 ${r.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',u.length?`${Math.round(u.reduce((e,t)=>e+t,0)/u.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,P.jsx)(p.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return k.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),n=_r(d[5]),o=_r(d[6]),r=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]);_r(d[12]);var m=e(_r(d[13])),x=e(_r(d[14])),y=e(_r(d[15])),p=_r(d[16]),f=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),C=_r(d[23]),T=_r(d[24]),$=_r(d[25]),I=_r(d[26]),B=_r(d[27]),D=_r(d[28]),z=_r(d[29]),N=_r(d[30]),P=_r(d[31]);const M=({title:e,right:t,children:s,testID:l})=>(0,P.jsxs)(y.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,P.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(p.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const L=e=>(0,P.jsxs)(y.default,{style:{gap:6},children:[(0,P.jsxs)(p.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,P.jsxs)(p.Muted,{children:[e.time," \xb7 ",e.table?(0,k.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,P.jsx)(S.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,P.jsx)(h.BookingNeeds,{b:e,big:!0}),e.notes?(0,P.jsxs)(p.T,{children:["Notes: ",e.notes]}):(0,P.jsx)(p.Muted,{children:"No notes."}),e.allergies.length?(0,P.jsx)(y.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,P.jsxs)(p.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,v.allergenLabel)(e.allergen)} \u2014 ${(0,v.severityLabel)(e.severity)}`).join('; ')]})}):(0,P.jsx)(p.Muted,{children:"No allergies declared."}),(0,P.jsx)(s.ShowNumberButton,{b:e},`num-${e.id}`)]});const A=!0},1387,[1172,1383,813,1095,812,843,1140,1091,1117,863,17,1078,219,385,278,85,777,1098,1371,858,998,845,1089,1076,1316,804,1338,1385,1386,1115,1113,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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1388,[812,17,219,385,85,777,858,998,1389,804,1390,1392,8]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1389,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1390,[831,858,998,1389,1391,1392]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1391,[843]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1392,[219,1391]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(P,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(P,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:p,tile:y,display:j,day:k}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),M=k??(0,c.ymd)(a),D=C.filter(o=>o.rid===e&&o.date===M&&!o.removedAt).length,P=D?`${D} block${1===D?'':'s'} that day`:'';return y?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:D||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>p?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[p?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:p?15:x?22:17,weight:"semibold",colour:p?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),D?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:D})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,Object.defineProperty(_e,"isSeasonAreaClose",{enumerable:!0,get:function(){return M}}),_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed,p=x&&m.active.length>0&&m.active.every(M),y=p?'Reopen garden, closed for winter':'Reopen garden';return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?p?'Closed for winter':'Closed for weather':'For weather',accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?y:'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=P;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),p=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function y({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),y=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return y.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[y.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',p(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${p(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function k({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[p,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),I=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),T=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:p,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(y,{testID:"block-today",title:"Today",sub:I?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!I,onPress:()=>m('today')}),(0,f.jsx)(y,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(y,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(y,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${T}`,onPress:()=>H(B,P,T)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(k,{value:p,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}const M=e=>!!e.areaId&&(!!e.wholeDay||(0,c.toMins)(e.from)<=0&&(0,c.toMins)(e.to)>=(0,c.toMins)('23:59'));function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(y,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function P({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;if(t.active.every(M))return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1393,[843,17,1183,1172,385,85,995,998,862,863,804,777,1394,1397,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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1394,[1395,854,843,17,264,378,385,278,85,858,995,998,1396,863,804,1026,777,1397,1350,899,1338,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1395,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1396,[862,863,861]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1397,[805,998,928,899]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:T,now:b,turnBase:v,blocks:w=[],height:M=150,forecastNote:k,emptyText:D,past:L,closed:I,compact:$=!1,dense:C=!1,bare:A=!1,fill:z=!1,fit:O=!1,tight:_=!1,live:H=!1,onChrome:S}){const[F,P]=(0,t.useState)(0),[E,R]=(0,t.useState)(0),[N,B]=(0,t.useState)(0),[W,X]=(0,t.useState)(0);s.default.useEffect(()=>{S&&O&&W&&S(Math.ceil((A?4:C?2:10)+N+W+(A?2:6)+2))},[S,O,N,W,A,C]);const U=j.getTime()-18e5,G=T.getTime()+36e5,Y=(0,t.useMemo)(()=>(0,f.coverCurve)(e,new Date(U),new Date(G),v),[e,U,G,v]),V=60*j.getHours()+j.getMinutes(),K=60*T.getHours()+T.getMinutes(),Z=(0,t.useMemo)(()=>(0,p.chartBands)(w,V,K),[w,V,K]),q=new Date(j);q.setHours(0,0,0,0);const J=e=>q.getTime()+6e4*e,Q=Math.max(8,...Y.map(e=>e.covers)),ee=Y.reduce((e,t)=>!t.covers||(0,p.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),Z)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),te=O&&E?Math.max(24,Math.floor(E)):Math.max(48,M-m.AXIS_BAND),se=m.CHART_PAD_L,ie=m.CHART_PAD_R,oe=C?18:22,ne=Math.max(10,F-se-ie),le=Math.max(10,te-oe-14),re=e=>se+(e-U)/(G-U)*ne,ae=e=>oe+le-e/(1.15*Q)*le,he=(0,m.yTicks)(Q),de=(0,m.fitYTicks)(he,ae,te,13),ue=(0,m.nowLineVisible)({now:b,open:j,close:T,live:H,past:L,closed:I}),ce=b.getTime(),ge=ue&&Y.length?(0,m.splitCurve)(Y,ce):{before:Y,after:[]},xe=e=>e.map((e,t)=>`${t?'L':'M'}${re(e.t).toFixed(1)},${ae(e.covers).toFixed(1)}`).join(' '),me=[];for(let e=new Date(U);e.getTime()<=G;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=U&&t.getTime()<=G&&me.push(t.getTime())}const pe=H?(0,m.seatedNowCovers)(e,e[0]?.date??''):0,fe=Math.min(G,Math.max(U,b.getTime())),ye=I?null:H?{t:fe,covers:pe,text:(0,m.seatedNowText)(pe)}:ee,je=F?(0,m.layoutChart)({width:F,height:te,t0:U,t1:G,hours:me,busiest:ye}):{hours:[],busiest:null},Te=xe(Y),be=ue?xe(ge.before):Te,ve=ue?xe(ge.after):'',we=z&&Te&&Y.length>1?`${Te} L${re(Y[Y.length-1].t).toFixed(1)},${ae(0).toFixed(1)} L${re(Y[0].t).toFixed(1)},${ae(0).toFixed(1)} Z`:'',Me=(0,i.coversFour)(e,e[0]?.date??''),ke=`Total ${Me.total} ${1===Me.total?'Cover':'Covers'}`,De=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,Le=je.busiest?.text??(I?'':H?(0,m.seatedNowText)(pe):ee?(0,m.busiestText)(ee.t,ee.covers):''),Ie=Z.map(e=>e.spoken).join('. '),$e=ue&&T.getTime()>j.getTime()?Math.max(0,Math.min(100,Math.round((ce-j.getTime())/(T.getTime()-j.getTime())*100))):null,Ce=!I&&ee&&ee.covers?(0,m.peakOccupancyText)(ee.t,ee.covers):'',Ae=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(T)}.${Ce?` ${Ce}.`:''}${Le?` ${Le}.`:''}${ue?` It is ${(0,u.hm)(b)}. About ${$e} percent of the way through the day.`:''}${Ie?` ${Ie}.`:''}`,ze=(0,u.hm)(b),Oe=Math.max(44,12*ze.length*.7+16),He=Math.max(se+2,Math.min(Math.max(0,F-ie-Oe),re(ce)-Oe/2)),Se=Math.max(2,Math.min(te-22,oe+le-22)),Fe=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(o.default,{testID:"day-graph",style:[d.look.panel,O?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:A?4:C?2:10,paddingBottom:A?2:6,backgroundColor:c.colours.bg}],children:[(0,y.jsxs)(o.default,{testID:"day-graph-head",onLayout:e=>B(e.nativeEvent.layout.height),children:[A?null:$?(0,y.jsxs)(o.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:ke}),Ce?(0,y.jsx)(h.T,{center:!0,size:13,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,children:Ce}):null]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:C?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:ke})]}),A||_?null:I?k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:k}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),Ce&&!$?(0,y.jsx)(h.T,{size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,center:!0,style:{flex:1,minWidth:0},children:Ce}):k?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:k}):(0,y.jsx)(o.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(T)]})]}),A||_||$||!k||!Ce?null:(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:1,style:{paddingHorizontal:14},children:k}),A||!_||!Ce||$?null:(0,y.jsx)(h.T,{center:!0,size:12,colour:c.colours.goldLight,testID:"day-graph-peak",numberOfLines:1,style:{paddingHorizontal:14},children:Ce})]}),(0,y.jsxs)(o.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:Ae,onLayout:e=>{P(e.nativeEvent.layout.width),O&&R(e.nativeEvent.layout.height)},style:O?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,M-m.AXIS_BAND),minHeight:24,overflow:'hidden',position:'relative'}:{height:te,minHeight:te,position:'relative',overflow:'hidden'},children:[F?(0,y.jsxs)(l.default,{width:F,height:te,children:[(0,y.jsxs)(n.Defs,{children:[(0,y.jsxs)(n.Pattern,{id:`${Fe}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(n.Pattern,{id:`${Fe}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(n.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(n.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),Z.map((e,t)=>(0,y.jsx)(n.Rect,{x:re(J(e.fromMin)),y:oe,width:Math.max(3,re(J(e.toMin))-re(J(e.fromMin))),height:le,fill:`url(#${Fe}-${e.strength})`},`${e.fromMin}-${t}`)),he.map(e=>(0,y.jsx)(n.Line,{x1:se,x2:se+ne,y1:ae(e),y2:ae(e),stroke:c.colours.muted,strokeWidth:1,opacity:.28},`grid-${e}`)),ue?(0,y.jsx)(n.Rect,{testID:"day-graph-elapsed",x:re(j.getTime()),y:oe,width:Math.max(0,re(ce)-re(j.getTime())),height:le,fill:c.colours.gold,opacity:.12}):null,we?(0,y.jsx)(n.Path,{d:we,fill:"#3A2F1E",stroke:"none"}):null,be?(0,y.jsx)(n.Path,{d:be,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,ve?(0,y.jsx)(n.Path,{d:ve,stroke:c.colours.gold,strokeWidth:2.5,fill:"none",opacity:.38}):null,I?null:[j,T].map((e,t)=>(0,y.jsx)(n.Line,{x1:re(e.getTime()),x2:re(e.getTime()),y1:oe,y2:oe+le,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),ue?(0,y.jsx)(n.Line,{testID:"day-graph-now",x1:re(ce),x2:re(ce),y1:oe,y2:oe+le,stroke:c.colours.gold,strokeWidth:2}):null,je.busiest?(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:je.busiest.x+je.busiest.w/2,y:je.busiest.y+je.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:je.busiest.text}):null,De?null:(0,y.jsx)(n.Text,{fontFamily:"Poppins_500Medium",x:se+ne/2,y:oe+le/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null,F?de.map(e=>(0,y.jsx)(o.default,{testID:"day-graph-ytick",pointerEvents:"none",style:{position:'absolute',left:0,width:se-4,top:e.top,alignItems:'flex-end',justifyContent:'flex-start'},children:(0,y.jsx)(h.T,{size:e.font,numberOfLines:1,colour:c.colours.muted,style:{textAlign:'right'},children:String(e.value)})},`yt-${e.value}`)):null,F&&ue&&te>=m.YTICK_MIN_PLOT?(0,y.jsx)(o.default,{testID:"day-graph-now-label",pointerEvents:"none",style:{position:'absolute',left:He,top:Se,minWidth:Oe,height:20,paddingHorizontal:8,borderRadius:10,backgroundColor:c.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(h.T,{size:12,weight:"semibold",colour:c.colours.bg,center:!0,numberOfLines:1,children:ze})}):null]}),(0,y.jsxs)(o.default,{testID:"day-graph-axis",onLayout:e=>X(e.nativeEvent.layout.height),style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(o.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),je.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,F)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,F-t),s));return(0,y.jsx)(o.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':in.fromMin-t.fromMin||n.toMin-t.toMin||(n.strength===t.strength?0:'area'===n.strength?-1:1));const l=[];for(const n of f){const t=l[l.length-1];t&&t.strength===n.strength&&n.fromMin<=t.toMin?(t.toMin=Math.max(t.toMin,n.toMin),t.spoken.includes(n.spoken)||(t.spoken=`${t.spoken}. ${n.spoken}`)):l.push({...n})}return l},e.blockedHours=function(n){const t=new Set;for(const o of n)if('venue'===o.strength)for(let n=Math.floor(o.fromMin/60);60*n=30&&t.add(n)}return[...t].sort((n,t)=>n-t)},e.minuteInsideVenueBlock=function(n,t){return t.some(t=>'venue'===t.strength&&n>=t.fromMin&&n{const t=/^(\d{1,2}):(\d{2})/.exec(n);return t?60*Number(t[1])+Number(t[2]):null},t=n=>`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`;function o(n,o,s){const a=`${t(o)} to ${t(s)}`,c=n.privateFunction?.title?.trim();if(!n.areaId&&!n.tables?.length){const n=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${n}, ${c}`:n}}const u=`${n.areaName?.trim()||(n.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}function s(t,o,s){const a=new Set;for(const c of t){if(c.removedAt||!c.areaId)continue;const t=c.wholeDay?0:n(c.from),u=c.wholeDay?1440:n(c.to);null!=t&&null!=u&&(t<=o&&u>=s&&a.add(c.areaId))}return a}},1399,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1400,[1076]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1401,[843,1379]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1402,[17,385,85,777,1401,804,1358,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1403,[17,85,884,777,1172,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}),Object.defineProperty(_e,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1404,[17,1172,385,85,409,777,8]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1405,[17,1005,876,926,816,1006,916,1350,1066]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1406,[805,813,857,17,219,385,85,409,899,804,777,1346,1407,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1407,[]); +__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]})}},1408,[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]})}},1409,[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,{})}},1410,[13,17,1411,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1411,[]); +__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]})}},1412,[13,17,856,1413,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)','')}})}},1413,[1414,1418,813,912,1072,1419,1203,1204,1028,1025,1026,1420,1422,1425,1153,891,978,1427,975,880,1031,1032,1428,914,1008,915,17,1155,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1161,1429,1066,1084,1086,1081,1027,1010,1057,1436,1437,1438,1446,1447,920,219,1236,1176,1182,1443,1196,1193,1452,1179,878,1206,1207,884,776,899,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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1414,[812,17,1018,378,85,1108,1109,1360,1393,777,995,998,863,804,1057,999,1415,1416,1020,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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1415,[812,17,385,85,777,804,998,805,999,856,899,8]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1416,[17,85,777,998,1417,842,804,1038,928,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1417,[]); +__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']]},1418,[17,85,777,1057,899,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)},1419,[843,17,85,777,845,851,1154,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)}}})]})}},1420,[899,17,264,219,85,1275,777,1252,1255,804,1421,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},1421,[17,219,85,777,1252,8]); +__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}},1422,[17,779,85,777,845,1252,1423,1424,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'},1423,[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()})},1424,[899,1423,1255]); +__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'})})}},1425,[805,1426,17,85,777,851,1252,1253,1254,899,1255,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1426,[]); +__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}},1427,[219,976]); +__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]},1428,[17,85,777,804,914,1022,899,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:W}={}){const{rid:ie,r:ae,now:oe,today:de,me:re,role:ue}=(0,w.useCtx)(1e4),ce=(0,A.useBookings)(ie),he=(0,w.useInStaffApp)(),ge=(0,w.useShiftManager)(),be=(0,A.useWaitlist)(ie),[pe,ke]=((0,A.useStore)(e=>e.alertAcks),(0,O.useState)(de)),xe=(0,K.useFrontDoor)(pe),me=(0,y.useBookingWrite)(),we=(0,f.useSeatClearFinish)(),[ye,je]=(0,O.useState)(''),[fe,Ie]=(0,O.useState)(!1),[Be,De]=(0,O.useState)(2),Se=pee.date===pe).sort((e,s)=>e.time.localeCompare(s.time)),Ce=be.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=$e.filter(e=>'noshow'===e.status),Le=(0,ee.useSync)(e=>!!e.venueId&&'guest'!==e.kind),ve=$e.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Ne=(0,p.cancelledDayTally)(ce,pe),Pe=(0,p.cancelledTallyWords)(Ne,pe===de?'today':'that day'),Oe=$e.filter(e=>!e.walkIn),We=$e.filter(e=>e.walkIn),Me=ce.filter(e=>'pending'===e.status&&e.date>=de).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Ee,Ae]=(0,O.useState)(null),Re=(0,H.parseYmd)(pe);Re.setHours(12);const ze=(0,le.hoursFor)(ae,Re),He=ze?.open??new Date(`${pe}T12:00:00`),Ge=ze?.close??new Date(`${pe}T21:00:00`),Fe=ze||$e.length?Se?'No one seated that day':pe===de?'No bookings yet today':'No bookings yet':pe===de?'Closed today':'Closed that day',Ue=Ce.length>0||fe||'waitlist'===W?(0,ne.jsxs)(M.default,{style:{gap:10},children:[(0,ne.jsx)(U.SectionHead,{title:`Waitlist (${Ce.length})`,sub:`New party waits about ${(0,G.estimateWait)(Ce.length+1,ae.settings.turnMins,1)} min (estimate)`}),Ce.map((e,s)=>(0,ne.jsxs)(M.default,{style:E.styles.card,children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,ne.jsxs)(E.Muted,{children:[(0,H.minsBetween)(new Date(e.joinedAt),oe)," min \xb7 est. ",(0,G.estimateWait)(s+1,ae.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,ne.jsx)(E.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,ne.jsxs)(E.Row,{gap:6,children:['waiting'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>A.repo.waitlist.setStatus(e.id,'notified')}):null,we.ok?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",onPress:()=>A.repo.waitlist.setStatus(e.id,'seated')}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>A.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ye,onChangeText:je,style:[E.styles.input,{flex:1}]}),(0,ne.jsx)(E.Stepper,{value:Be,onChange:De,min:1,max:12,label:"party"})]}),(0,ne.jsx)(E.Button,{kind:"secondary",label:"Add to waitlist",disabled:ye.trim().length<2,onPress:()=>{A.repo.waitlist.join(ie,ye.trim(),Be),je('')}})]}):(0,ne.jsx)(E.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>Ie(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===W?(0,ne.jsx)(M.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Ue}):(0,ne.jsxs)(M.default,{style:{gap:12},children:[(0,ne.jsx)(l.BookingSaveBanner,{rid:ie}),e&&!he&&'staff'!==ue?(0,ne.jsx)(E.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'===ie)&&!he&&'staff'!==ue?(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"table"}):null,!s.IS_WILDINGS&&!ae.settings.hotel?.enabled||he||'staff'===ue?null:(0,ne.jsx)(i.VenueRequestList,{rid:ie,kind:"room",hotel:ae.settings.hotel??n.WILDINGS_HOTEL}),(0,ne.jsx)(Q.BookingsDayNav,{today:de,date:pe,onDate:ke,count:e=>ce.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ce.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,ne.jsx)(M.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,ne.jsx)(te.DayGraph,{bare:!0,fill:!0,todays:$e,open:He,close:Ge,now:oe,turnBase:ae.settings.turnMins,height:128,past:Se,closed:!ze,emptyText:Fe})}),Se?(0,ne.jsxs)(M.default,{testID:"bookings-past-totals",style:[E.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,Q.longDay)(pe)}: ${Oe.length} tables, ${ve} Covers, ${$e.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${$e.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,ne.jsxs)(E.T,{size:17,weight:"semibold",children:["That day: ",Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']}),(0,ne.jsxs)(E.T,{size:16,colour:F.colours.text,children:[$e.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",$e.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,ne.jsx)(E.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,ne.jsx)(M.default,{testID:"bookings-summary",children:(0,ne.jsxs)(E.T,{weight:"semibold",children:[Oe.length," booking",1===Oe.length?'':'s',We.length?` \xb7 ${We.length} walk-in${1===We.length?'':'s'}`:''," \xb7 ",ve," ",1===ve?'Cover':'Covers']})}),he||'staff'===ue||Se?null:(0,ne.jsx)(h.BookingsMatchStatus,{}),(0,ne.jsx)(M.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Pe,style:{alignItems:'center'},children:(0,ne.jsx)(E.T,{size:15,colour:F.colours.muted,center:!0,children:Pe})}),(0,ne.jsxs)(M.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[Se||he&&!ge?null:(0,ne.jsx)(T.QuietButton,{label:"New booking",onPress:xe.openBooking,testID:"add-booking",disabled:!me.ok,accessibilityHint:me.hint}),he&&ge&&pe===de?(0,ne.jsx)(T.QuietButton,{label:"Walk-in",onPress:xe.openWalkIn,testID:"add-walkin",disabled:!me.ok,accessibilityHint:me.hint}):null,pe===de?(0,ne.jsx)(L.CloseGardenButton,{quiet:!0,short:!0,rid:ie,r:ae,now:oe,by:re}):null]}),Me.length?(0,ne.jsxs)(M.default,{testID:"pending-requests",style:[E.styles.card,{borderColor:F.colours.amber,gap:8}],children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:F.colours.amber,children:["Needs confirming (",Me.length,")"]}),(0,ne.jsx)(E.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Me.map(e=>(0,ne.jsxs)(M.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:F.colours.border},children:[(0,ne.jsxs)(E.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,ne.jsxs)(E.Muted,{children:[(0,H.niceDate)((0,H.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,ne.jsxs)(E.T,{size:16,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`pending-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae}),'staff'!==ue&&((0,N.needsHoldOk)(e)||e.date===de&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,N.needsHoldOk)(e)?(0,ne.jsx)(E.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,v.confirmHolds)(e.id,re)}):null,e.holdOk&&'seated'===e.status?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,v.serveHolds)(e,re,'owner')}):null]}):null,Ee===e.id?(0,ne.jsxs)(M.default,{style:{gap:6},children:[(0,ne.jsxs)(E.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,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{A.repo.bookings.decide(e.id,'declined',re),Ae(null)}}),(0,ne.jsx)(E.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ae(null)})]})]}):me.ok?(0,ne.jsxs)(E.Row,{gap:6,children:[(0,ne.jsx)(E.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>A.repo.bookings.decide(e.id,'confirmed',re)}),(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ae(e.id)}),(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"change"})]}):(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===$e.length?(0,ne.jsx)(E.Muted,{children:"No bookings for this day yet."}):null,$e.map(e=>{const s='confirmed'===e.status&&pe===de&&(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,z.gbp);return(0,ne.jsxs)(M.default,{testID:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[E.styles.card,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,P.seatedHighlightStyle)({borderColor:(0,N.hasAllergens)(e)?F.colours.red:F.colours.goldLight}):{borderColor:(0,N.hasAllergens)(e)?F.colours.red:s?F.colours.amber:F.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,ne.jsx)(v.AllergenBar,{b:e}),(0,ne.jsx)(l.BookingNotSavedLine,{b:e}),(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsxs)(E.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,ne.jsxs)(E.T,{weight:"semibold",colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?P.SEATED_FG:F.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,K.walkInLabel)(e)]}),(0,N.hasAllergens)(e)?(0,ne.jsx)(_.AllergyIcon,{text:(0,N.allergenText)(e),size:20,colour:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?'#7A4A00':F.colours.amber,ink:(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?F.colours.gold:F.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,ne.jsx)(E.Badge,{kind:'seated'===(0,N.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,N.shownStatus)(e)[0].toUpperCase()+(0,N.shownStatus)(e).slice(1)})]}),n?(0,ne.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,P.isSeatedHighlight)((0,N.shownStatus)(e))?(0,ne.jsxs)(E.T,{size:14,colour:P.SEATED_MUTED,children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,ne.jsxs)(E.Muted,{children:[e.table?(0,Y.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,ne.jsxs)(E.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,D.guestChangeLine)(e)?(0,ne.jsx)(E.T,{size:15,colour:F.colours.amber,testID:`booking-guest-change-${e.id}`,children:(0,D.guestChangeLine)(e)}):null,(0,b.bookingExtras)(e)?(0,ne.jsx)(E.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,ne.jsx)(v.NeedsPills,{b:e,r:ae,only:"rules"}),(0,b.historyLines)(e)[0]?(0,ne.jsxs)(E.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[Se||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,K.walkInLabel)(e)}`,onPress:()=>A.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:re,depositPaidAt:(new Date).toISOString()})}),Se?null:(0,ne.jsx)($.WixDepositLink,{b:e,rid:ie}),Se||!me.ok||he&&!ge?null:(0,ne.jsx)(S.WaiveDepositButton,{b:e,who:re,small:!0}),'waived'===t&&e.depositWaived?(0,ne.jsx)(E.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,ne.jsx)(E.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,ne.jsxs)(E.Muted,{children:[(0,Z.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,ne.jsx)(E.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,ne.jsx)(E.Badge,{kind:"red",label:`${(0,R.allergenLabel)(e.allergen)} \xb7 ${(0,R.severityLabel)(e.severity)}`},e.allergen))}):null,(0,N.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,ne.jsx)(J.BookingAllergyChain,{b:e,me:re}):null,e.walkIn?null:(0,ne.jsx)(X.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,ne.jsxs)(E.T,{size:13,colour:F.colours.amber,children:["Running ",(0,H.minsBetween)(new Date(`${e.date}T${e.time}:00`),oe)," min late. Call them, then mark no-show if needed."]}):null,me.ok?(0,ne.jsx)(c.BookingEditButton,{rid:ie,booking:e,who:re,role:ue,inStaffApp:he,shiftManager:ge,big:!0,testID:`edit-booking-${e.id}`}):null,(0,ne.jsxs)(E.Row,{wrap:!0,gap:6,children:[(0,ne.jsx)(u.BookingTableButton,{rid:ie,booking:e,readOnly:Se||!me.ok,turnBase:ae.settings.turnMins,canClear:we.ok}),me.ok?null:(0,ne.jsx)(M.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,ne.jsx)(E.T,{children:j.BOOKING_VIEW_ONLY})}),me.ok?(0,ne.jsxs)(ne.Fragment,{children:[Se||e.table||!['seated','confirmed'].includes(e.status)?null:(0,ne.jsx)(E.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>xe.assignTable(e)}),!Se&&['seated','confirmed'].includes(e.status)?(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,Y.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,K.walkInLabel)(e)}`,onPress:()=>xe.combineTables(e)}):null,Se||'confirmed'!==e.status?null:(0,ne.jsxs)(ne.Fragment,{children:[we.ok&&e.date===de?(0,ne.jsx)(E.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,K.walkInLabel)(e)} now`,onPress:()=>(0,K.seatBookingNow)(ie,e)}):null,(0,ne.jsx)(E.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>A.repo.bookings.setStatus(e.id,'noshow')})]}),Se||e.walkIn?null:(0,ne.jsx)(r.CancelBookingButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),small:!0,onDone:()=>{}}),Se||e.walkIn?null:(0,ne.jsx)(r.ReinstateBookingButton,{b:e,name:(0,K.walkInLabel)(e),today:de}),Se||'seated'!==e.status?null:(0,ne.jsx)(V.FinishButton,{rid:ie,b:e,name:(0,K.walkInLabel)(e),allowed:we.ok,hint:we.hint,small:!0,a11y:`Finished: ${(0,K.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=de?(0,ne.jsx)(se.WhatsAppGuest,{b:e,rid:ie,kind:"auto"}):null,he?null:(0,ne.jsx)(C.CopyReviewLink,{rid:ie,bookingId:e.id}),!Se&&e.walkIn?(0,ne.jsx)(d.CancelWalkInButton,{rid:ie,b:e,small:!0}):null,!Se&&e.walkIn?(0,ne.jsx)(d.ReinstateWalkInButton,{rid:ie,b:e,today:de,small:!0}):null,(0,ne.jsx)(q.BookingUndo,{b:e,rid:ie,today:de,who:(0,K.walkInLabel)(e),allowed:we.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,ne.jsx)(E.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,ne.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ce,pe,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:pe===de?'today':'that day'}),(0,ne.jsxs)(E.Card,{children:[(0,ne.jsxs)(E.Row,{style:{justifyContent:'space-between'},children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"No-shows"}),(0,ne.jsx)(E.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${pe===de?'today':(0,H.niceDate)((0,H.parseYmd)(pe)).slice(0,6)}${Le||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,ne.jsx)(E.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,K.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,ne.jsx)(t.GreensideCashOnly,{}):(0,ne.jsxs)(E.Card,{children:[(0,ne.jsx)(E.T,{weight:"semibold",children:"Deposits"}),(0,ne.jsx)(E.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ae.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,z.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,ne.jsx)(E.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Ue,xe.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]),C=_r(_d[25]),T=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=_r(_d[32]),M=(e=W)&&e.__esModule?e:{default:e},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]),ne=_r(_d[54])},1429,[805,1426,1095,1262,1430,812,822,1117,1118,1091,1122,1431,1114,1119,1401,1402,1057,1338,996,1120,1089,841,1380,1125,1433,1231,1434,1393,1078,1055,1090,17,85,777,1358,858,845,851,863,1316,804,1178,1098,1115,998,1355,1062,1162,1435,1222,899,1180,1398,862,8]); +__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])},1430,[806,17,85,777,899,1266,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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1431,[17,385,85,1432,899,928,804,777,8]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1432,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1433,[812,805,17,362,219,85,777,860,841,851,1001,928,804,1181,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1434,[17,385,1172,777,804,8]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1435,[17,85,864,858,848,804,777,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])},1436,[17,1394,1057,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])},1437,[843,17,85,1162,777,858,845,853,863,804,1178,1057,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})},1438,[820,896,1439,17,219,85,777,816,876,895,1000,897,899,1445,804,880,1163,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.Insights=function({go:e}){const{rid:t,r:s,now:l,today:n}=(0,v.useCtx)(6e4),i=(0,j.useBookings)(t),a=(0,j.useOrders)(t),r=(0,j.useEvents)(t),o=(0,j.useRatings)(t),c=(0,T.seatedCoversOn)(i,n),u=(0,T.laterTodayCovers)(i,n),h=(0,d.useMemo)(()=>(0,B.insights)(s,i,a,r,o,l,c),[s.id,i.length,a.length,o.length,c,u]);return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Muted,{children:(0,D.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),h.map((t,s)=>(0,H.jsx)(I.FadeIn,{delay:80*s,children:(0,H.jsxs)(x.Card,{highlight:F[t.tone],children:[(0,H.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,H.jsx)(x.T,{size:22,children:t.icon}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,D.useExamples)()?(0,H.jsx)(U,{}):(0,H.jsx)(_,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,D.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,B.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,B.quadrant)(e.sold,e.margin,r,o)}));return l?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,H.jsx)(I.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,H.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,H.jsxs)(x.Row,{gap:4,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,H.jsx)(x.Muted,{children:e})]},e))}),(0,H.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,H.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,H.jsx)(x.Muted,{children:B.QUADRANT_TIP[e]}),t.map(e=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,H.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,$.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,H.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,H.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,H.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,P.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,B.stockList)();return(0,H.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,H.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,H.jsx)(x.Card,{children:(0,H.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,R.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,H.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,H.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,H.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,H.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,H.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,H.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.name}),(0,H.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,H.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,H.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,H.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,H.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,H.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,H.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,H.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,H.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,H.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,H.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,H.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,H.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,H.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:q.map(t=>(0,H.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,H.jsx)(x.Card,{children:(0,H.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,H.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,D.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,H.jsxs)(g.default,{style:{gap:10},children:[i?(0,H.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,H.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,H.jsxs)(x.Row,{gap:8,children:[k?(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Referrals"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,H.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Gift card sales"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,H.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,H.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,H.jsx)(M.PostToSocialButtons,{onPick:t=>(0,M.shareToSocial)(e,{group:t})}),(0,H.jsx)(M.QuickLinksSection,{go:e,heading:e=>(0,H.jsx)(C.SectionHead,{title:e})}),(0,H.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,H.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,H.jsx)(x.Muted,{children:e.body}),(0,H.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,H.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,H.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,H.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,H.jsx)(x.Muted,{children:"Audience"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,H.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,H.jsx)(x.Muted,{children:"When"}),(0,H.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,H.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,H.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,H.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.title}),(0,H.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,E.venueInfo)().name}. Book in the app.`)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,M.shareToSocial)(e,(0,M.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,H.jsxs)(g.default,{style:{gap:12},children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,H.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,H.jsx)(x.Card,{children:(0,H.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=K.filter(e=>i[`${n}:${e.id}`]).length;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,H.jsx)(x.Badge,{kind:c===K.length?'ok':'amber',label:`${c}/${K.length}`})]}),(0,H.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,H.jsx)(g.default,{style:{height:8,width:c/K.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),K.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{size:14,children:e.label}),d?(0,H.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,H.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,H.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,H.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,H.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,H.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,H.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,H.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,H.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,H.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:e.item}),(0,H.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,H.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,H.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,H.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,H.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:"semibold",children:t.item}),(0,H.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,H.jsxs)(x.Muted,{children:[t.where," \xb7 found ",W(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,H.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,H.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,H.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,H.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=V,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=V(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${G.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,H.jsx)(g.default,{testID:"alerts-select-bar",children:(0,H.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,H.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,H.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,H.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,H.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,H.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,H.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,H.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,H.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,H.jsx)(x.Muted,{children:S})}):null,L?(0,H.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,H.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:G.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,H.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,H.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,H.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,H.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,H.jsx)(x.Card,{children:(0,H.jsxs)(x.Row,{gap:10,children:[(0,H.jsx)(r.KindIcon,{kind:"email"}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,H.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,H.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,H.jsxs)(x.Row,{gap:10,children:[$?(0,H.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,H.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,H.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,H.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,H.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,H.jsxs)(g.default,{style:{flex:1},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,H.jsx)(x.Muted,{children:Y(e.at)})]}),(0,H.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,H.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,H.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,H.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,H.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,H.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,H.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,B.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,H.jsxs)(g.default,{style:{gap:8},children:[(0,H.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,H.jsxs)(x.Card,{onPress:e.on,children:[(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsx)(x.T,{style:{flex:1},children:e.t}),(0,H.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,H.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,H.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,H.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,H.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsxs)(x.Card,{children:[null,(0,H.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,H.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=X,_e.copyText=J,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,H.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,H.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Q.map(l=>{const n={...l,name:(0,E.venueInfo)().name+l.name},i=X(n.path);return(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:n.name}),(0,H.jsx)(x.Muted,{children:n.who}),(0,H.jsx)(x.Row,{gap:10,children:(0,H.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,H.jsx)(x.Row,{gap:6,children:(0,H.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await J(X(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]),H=_r(_d[38]);const z={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},F={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},W=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,A.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,N.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,L.clampWeeks)(t.settings.forecastMinWeeks);return(0,H.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,H.jsx)(I.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,H.jsx)(P.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,H.jsxs)(x.Card,{children:[(0,H.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,H.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,H.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function U(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,B.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=B.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,B.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,H.jsxs)(g.default,{style:{gap:10},children:[(0,H.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,H.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Revenue"}),(0,H.jsx)(I.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,H.jsx)(I.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,H.jsx)(I.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,H.jsxs)(x.Row,{gap:14,children:[(0,H.jsx)(I.Donut,{parts:p.map(e=>({value:e.v,colour:z[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,H.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,H.jsxs)(x.Row,{gap:6,children:[(0,H.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:z[e.c]}}),(0,H.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,H.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,H.jsxs)(x.Card,{children:[(0,H.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,H.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,H.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,H.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,H.jsxs)(x.Row,{gap:8,children:[(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"Repeat customers"}),(0,H.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,H.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,H.jsxs)(x.Card,{style:{flex:1},children:[(0,H.jsx)(x.Muted,{children:"No-show rate"}),(0,H.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,H.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,H.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,H.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,H.jsx)(I.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,H.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const q=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const K=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function V(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const G=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],Y=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Q=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function X(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function J(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1439,[812,891,1140,899,780,1220,1222,17,264,362,219,385,85,409,864,777,858,1231,876,851,863,804,1178,1057,853,1055,1440,1161,1443,1444,1139,1146,1145,1008,839,1142,1149,1215,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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1440,[886,779,816,813,822,862,1039,1441,17,909,319,362,219,385,85,777,858,876,863,804,1178,1057,1215,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1441,[482,1442]); +__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}});var t={}},1442,[]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{money:!0,label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{money:!0,label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1443,[812,17,1245,1026,854,362,385,85,777,876,851,863,804,1178,1057,1215,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,"PAGES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4),p=(0,c.useChatUnread)().total;return(0,f.jsxs)(o.default,{style:{gap:14},children:[h.map(t=>{const u=g.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(o.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(n.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),'chat'===t.id&&p?(0,f.jsx)(s.Badge,{kind:"red",label:String(p)}):t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===b.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),b=r(d[9]),f=r(d[10]);const g=[],p=e=>{e.forEach(e=>{g.some(t=>t.id===e.id)||g.push(e)})},h=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const j=e=>g.find(t=>t.id===e)},1444,[978,17,385,85,777,876,804,1057,1161,899,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'}},1445,[]); +__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)','')},1446,[843,17,85,777,876,998,863,1060,1058,899,1059,805,916,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}),Object.defineProperty(_e,"APP_USED_TEXT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return C}}),_e.personFromStaff=P,_e.signInWithText=H,_e.SignInWithLink=E,_e.signInWithHandover=O,_e.useSignedOutGate=function(){const e=(0,u.useSession)(e=>e.meId),t=(0,p.useSync)(e=>'device'===e.kind&&!!e.venueId);return r.IS_CAR?!m.PITCH&&!t:x.includes(r.APP_VARIANT)&&!m.PITCH&&!e&&!z()},_e.InviteGate=function(){const[e,A]=(0,n.useState)(u.useSession.persist.hasHydrated()),[P,H]=(0,n.useState)(u.START_INVITE||u.START_HANDOVER||u.START_KITCHEN?'checking':'done'),[V,M]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),[K,L]=(0,n.useState)(0),[U,Y]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),X=(0,u.useSession)(e=>e.meId),$=(0,u.useSession)(e=>!X||!!e.welcomed[X]);if((0,n.useEffect)(()=>{const e=u.useSession.persist.onFinishHydration(()=>A(!0));return u.useSession.persist.hasHydrated()&&A(!0),e},[]),(0,n.useEffect)(()=>{if(!e||!x.includes(r.APP_VARIANT))return;let t,n=!0;return(async()=>{const e=u.useSession.getState().meId;if(u.START_KITCHEN&&'chef'===r.APP_VARIANT&&!e){const e=await(0,p.claimDisplayKitchen)(u.START_KITCHEN);if(!n)return;if('ok'===e.status&&e.id.staffRef){(0,k.markKitchenViaDisplay)(!0,e.id.displayName),N(e.id);try{u.useSession.getState().markWelcomed(e.id.staffRef)}catch{}return void H('done')}return M('refused'===e.status?e.message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'),void H('done')}if(u.START_HANDOVER&&!u.START_INVITE&&!D){D=!0;const t=await(0,p.claimChromeHandover)(u.START_HANDOVER);if(!n)return;if('ok'===t.status&&t.id.staffRef)N(t.id);else if('refused'===t.status&&!e)return W(t.message),void H('done')}if(u.START_INVITE&&!(e&&await(0,p.signedInHereAs)(e)&&await(0,p.rememberedInviteHere)(u.START_INVITE))){const e=await _(u.START_INVITE,e=>{n&&W(e)});if(!n)return;if('refused'===e.kind)return W(e.message),void H('done');if('offline'===e.kind)return Y(!0),void(t=setTimeout(()=>{n&&L(e=>e+1)},1e4));if(Y(!1),'bad'===e.kind)return void H('bad')}const s=R(u.useSession.getState().meId),o=s&&!1!==b.useOwner.getState().staff.find(e=>e.id===s.id)?.active;if(s&&!o)u.useSession.getState().signOut();else if(s&&!j(s)&&!u.START_INVITE&&await(0,p.signedInHereAs)(s.id)){if(await(0,p.forgetSignInHere)(),!n)return;u.useSession.getState().signOut(),G(C(s.app))}else if(s&&!j(s)){const e=(0,u.appUrl)(s.app,u.START_INVITE);if(e)return void window.location.replace(e)}H('done')})(),()=>{n=!1,t&&clearTimeout(t)}},[e,K]),!x.includes(r.APP_VARIANT))return null;const q=(0,t.IsolatedVenueWelcome)({meId:X,refused:F,waiting:U,hydrated:e,state:P});if(q)return q;if(U)return v('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===P)return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}]});if(r.IS_OWNER_DESKTOP&&!X&&!m.PITCH&&!z())return(0,I.jsx)(o.default,{style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3}],children:(0,I.jsx)(l.DesktopSignIn,{onCode:O,refused:F})});if((0,T.inPhoneApp)()&&!X&&!m.PITCH)return F&&/already been used/i.test(F)?v(S,'invite-app-used'):F&&(0,y.isPhoneLinked)(F)?v(y.PHONE_LINKED_TEXT,'invite-phone-linked'):F?v(F,'invite-app-refused'):v(w,'invite-app-notsetup');if('bad'===P)return(0,I.jsxs)(o.default,{testID:"invite-bad",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,I.jsx)(h.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal CoverCharge link."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>H('done')}),(0,I.jsx)(h.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(F&&!X&&(0,y.isPhoneLinked)(F))return(0,I.jsxs)(o.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${y.PHONE_LINKED_TEXT}`,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:24,weight:"bold",center:!0,colour:f.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,I.jsx)(h.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,I.jsx)(h.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(F&&!X)return(0,I.jsxs)(o.default,{testID:"invite-refused",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,I.jsx)(h.Muted,{center:!0,children:F}),(0,I.jsx)(h.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,I.jsx)(h.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>W(null)})]});if(B&&!X)return(0,I.jsxs)(o.default,{testID:"invite-moved",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,I.jsx)(h.Muted,{center:!0,children:B}),(0,I.jsx)(E,{})]});if(V&&!X){const e=/expired/i.test(V);return(0,I.jsxs)(o.default,{testID:e?'kitchen-unlock-expired':'kitchen-unlock-failed',style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e?'That unlock has expired':'Could not open the Head Chef app'}),(0,I.jsx)(h.Muted,{center:!0,children:V}),(0,I.jsx)(h.Muted,{center:!0,children:"Use Back to Display, then enter the unlock code again. Do not use a personal link on this tablet."})]})}if(!X&&!m.PITCH&&!z())return(0,I.jsxs)(o.default,{testID:"invite-signin",style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:F?'This link can\u2019t be used here':'Sign in to CoverCharge'}),F?(0,I.jsx)(h.Muted,{center:!0,children:F}):null,(0,I.jsx)(h.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,I.jsx)(E,{})]});const J=(0,u.rosterPerson)(X);return J&&!$&&j(J)&&!(0,k.isKitchenViaDisplay)()?(0,I.jsx)(c.LaunchWelcome,{p:J,onDone:()=>u.useSession.getState().markWelcomed(J.id)}):null};var t=_r(d[0]),n=_r(d[1]);_r(d[2]);var s=e(_r(d[3])),o=e(_r(d[4])),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),f=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),k=_r(d[12]),m=_r(d[13]),T=_r(d[14]),y=_r(d[15]),b=_r(d[16]),I=_r(d[17]);const S='This app copy has already been set up on another phone. Ask your manager for a new link.',w='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',v=(e,t)=>(0,I.jsx)(o.default,{testID:t,style:[s.default.absoluteFill,{backgroundColor:f.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,I.jsx)(h.T,{size:22,weight:"bold",center:!0,children:e})}),x=['owner','staff','chef'],j=e=>'staff'===r.APP_VARIANT||e.app===r.APP_VARIANT,C=e=>`You now use ${u.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function A(e){u.useSession.getState().signIn(e.id);const t=b.useOwner.getState();b.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}function P(e){const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:t,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===t?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const R=e=>{const t=(0,u.rosterPerson)(e);if(t)return t;const n=e?b.useOwner.getState().staff.find(t=>t.id===e):void 0;return n?P(n):void 0};async function _(e,t){const n=await(0,u.personForInvite)(e);if(n)return A(n),j(n)?((0,p.claimInvite)(e).then(e=>{if('refused'===e.status&&u.useSession.getState().meId===n.id&&(u.useSession.getState().signOut(),t(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==u.useSession.getState().meId){const t=R(e.id.staffRef);t&&A(t)}}),{kind:'ok',p:n}):{kind:'ok',p:n};const s=await(0,p.claimInvite)(e);if('refused'===s.status)return{kind:'refused',message:s.message};if('offline'===s.status)return{kind:'offline'};if('ok'!==s.status||!s.id.staffRef)return{kind:'bad'};const o=R(s.id.staffRef)??P({id:s.id.staffRef,name:s.id.displayName||s.id.staffRef,role:'owner'===s.id.role?'owner':'manager'===s.id.role?'manager':'staff',level:'head_chef'===s.id.role?'Head Chef':void 0,job:'',active:!0});return A(o),{kind:'ok',p:o}}async function H(e,t=()=>{}){const n=(0,u.inviteFromText)(e);if(!n)return'bad';const s=await _(n,t);if('refused'===s.kind)return{refused:s.message};if('bad'===s.kind||'offline'===s.kind)return'bad';const o=s.p;if(!j(o)){const e=(0,u.appUrl)(o.app,n);if(e)return window.location.replace(e),'moved'}return'ok'}function E(){const[e,t]=(0,n.useState)(''),[s,r]=(0,n.useState)('');return(0,I.jsxs)(o.default,{style:{gap:6},children:[(0,I.jsx)(h.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:t,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,I.jsx)(h.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const n=await H(e,r);r('bad'===n?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof n?n.refused:''),'ok'===n&&t('')}}),s?(0,I.jsx)(h.T,{size:13,colour:f.colours.red,children:s}):null]})}function N(e){if(!e.staffRef)return;A(R(e.staffRef)??P({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function O(e){const t=await(0,p.claimChromeHandover)(e);return'ok'===t.status?t.id.staffRef?(N(t.id),'ok'):'bad':'refused'===t.status?{refused:t.message}:'offline'===t.status?'offline':'bad'}let D=!1;const z=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1447,[1448,17,219,24,85,856,1449,920,804,1451,777,899,922,880,1069,918,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.IsolatedVenueWelcome=function(n){return null}},1448,[]); +__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])},1449,[17,278,85,777,857,804,1450,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(' ')},1450,[]); +__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),J='live'===$||'offline'===$,q=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:q})}):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:J?'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'],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]})}},1451,[888,813,17,1069,319,219,385,278,24,85,856,885,876,816,899,920,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.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])},1452,[1179,1072,1117,1089,17,385,85,777,876,863,804,1090,1171,1168,1057,1120,1176,1440,1162,860,1180,853,1178,884,1355,998,843,1115,1193,1200,1071,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]})}},1453,[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 q}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=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 n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{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]),O=r(_d[16]),P=r(_d[17]),_=r(_d[18]),j=r(_d[19]),v=r(_d[20]),b=r(_d[21]),A=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]),T=r(_d[31]),H=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),D=r(_d[40]),U=r(_d[41]);function q(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:D,Poppins_700Bold:U}),[s,C]=(0,d.useState)(b.useStore.persist.hasHydrated()),[H,F]=(0,d.useState)(x.useOwner.persist.hasHydrated()),B=s&&H;(0,d.useEffect)(()=>{const e=b.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>F(!0));return b.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(b.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&x.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,E.useSignedOutGate)(),q=(0,u.usePathname)(),K=V&&!(0,_.isAllowedPath)(q||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(_.ENTRY[_.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,q]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(v.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||_.IS_CAR?null:(0,G.jsx)(R.PushPrompt,{}),_.IS_CAR?(0,G.jsx)(j.CarGate,{}):(0,G.jsx)(E.InviteGate,{}),(0,G.jsx)(P.BackToDisplay,{}),K||N?null:(0,G.jsx)(T.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[O.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:O.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:w.colours.gold})]})}H.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:_.APP_VARIANT,useStore:b.useStore,useOwner:x.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:C.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1454,[1455,899,778,1407,1457,995,13,1484,479,17,368,319,219,24,85,805,857,1065,856,1486,19,858,998,876,804,1447,920,988,1489,1490,1028,1104,880,1008,914,1492,1377,8,1493,1494,1495,1496]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1455,[880,812,17,219,366,85,777,1456,899,804,1182,920,876,909,8]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1456,[]); +__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])},1457,[1458,1481,1483]); +__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)}}},1458,[198,1459,1462,1476,1477,1478,1479,1480]); +__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}},1459,[198,1460]); +__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}},1460,[1461]); +__d(function(g,r,i,a,m,e,d){},1461,[]); +__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)}},1462,[1463,198,1459,1476,1477]); +__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]}})})},1463,[1464,1465,1475]); +__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()}})}},1464,[1465,1469,1474]); +__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}}},1465,[198,355,1466,1470,1471,1472,1473,1469,1474]); +__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}},1466,[198,1467,322,263,1468,1469]); +__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])},1467,[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}}},1468,[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},1469,[]); +__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}},1470,[]); +__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}},1471,[]); +__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])},1472,[1470]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1473,[]); +__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},1474,[355,1468]); +__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])},1475,[17,1465]); +__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}},1476,[1463,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])},1477,[1463,1476]); +__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}},1478,[1459]); +__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])},1479,[198,1459,1462,1460]); +__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})({})},1480,[]); +__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]))},1481,[198,37,1482]); +__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')},1482,[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]}},1483,[17,1458]); +__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]}})})},1484,[1485]); +__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(){}},1485,[]); +__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]})}},1486,[17,24,85,409,777,857,920,899,880,805,804,1487,1488,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 o}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return l}}),e.menuSizes=function(o,l){const s=Math.round(Math.max(300,Math.min(o-24,o>=1600?520:o>=1200?460:420))),t=Math.floor((s-40-2)/3),n=Math.floor(Math.max(84,(l-72-40)/4)),c=l>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:s,colW:t,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 s}});const o=[{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'}]}],l=56;const s=o=>o.split('').join(' ')},1487,[]); +__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])},1488,[17,85,777,804,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()})},1489,[905,868,867,899]); +__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 C}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return I}}),_e.syncTone=S,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return R}}),_e.SyncBadge=function(){const e=(0,h.useSync)(),[I,k]=(0,s.useState)(!1),[A,$]=(0,s.useState)(e.refused?.at??''),P=e.refused&&e.refused.at!==A?e.refused:void 0,z=(0,p.useScreensaverAsleep)(e=>e.asleep),[W,L]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{const e=setInterval(()=>L(Date.now()),5e3);return()=>clearInterval(e)},[]);const N='off'===e.mode&&(x.PITCH||!(0,v.isSupabaseConfigured)());if('customer'===u.APP_VARIANT||'off'===e.mode&&!N)return null;if(z)return(0,w.jsx)(c.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:C,backgroundColor:f.colours.bg}});const O=!N&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,o.syncStale)(e.lastServerAt,W):'offline'===e.mode),H=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',_='live'===e.mode&&!O,E=e.waiting??0,B=`${E} change${1===E?'':'s'} waiting to save`,G=O?'Out of sync':N?x.PITCH?'Demo \xb7 this device only':'This device only':_?E?B: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',M=O?'disconnected':S(e.mode,N,E),F=D(M),V=O?`Out of sync: nothing from the shared system since ${H||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:N?x.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.':_?`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,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(c.default,{testID:"sync-strip",style:{height:C,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:f.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,w.jsxs)(l.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:E&&_?`${B}, ${R(M)}. Kept on this device and tried again by itself. Tap for details.`:`${G}, ${R(M)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>k(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:`${F}80`,maxWidth:320},children:[(0,w.jsx)(c.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:F}}),(0,w.jsx)(b.T,{size:12,weight:"semibold",children:G})]}),O?(0,w.jsx)(c.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:f.colours.red},children:(0,w.jsx)(b.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(H?` Last synced ${H}`:'')})}):null]}),I?(0,w.jsxs)(c.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,w.jsx)(b.T,{size:13,children:V}),E?(0,w.jsxs)(c.default,{testID:"sync-waiting",style:{gap:4},children:[(0,w.jsxs)(b.T,{size:12,colour:f.colours.gold,children:[B,". ",1===E?'It is':'They are'," kept on this device and tried again by ",1===E?'itself':'themselves'," until the shared system takes ",1===E?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,w.jsx)(l.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{y.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:f.colours.gold},children:(0,w.jsx)(b.T,{size:12,colour:f.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,w.jsxs)(b.T,{size:12,colour:f.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,w.jsx)(b.T,{size:12,colour:f.colours.muted,children:e.message}):null,(0,w.jsx)(T.SyncDeviceActions,{})]}):null,P?(0,w.jsx)(c.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:C+j+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,w.jsxs)(c.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:f.colours.red,maxWidth:460,gap:8},children:[(0,w.jsx)(b.T,{size:13,children:`Not saved: ${P.what}. Why: ${P.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,w.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>$(P.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=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),h=r(d[7]),y=r(d[8]),f=r(d[9]),b=r(d[10]),p=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),w=r(d[15]);const C=48,j='display'===u.APP_VARIANT?0:57,I='#3DD68C';function S(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const D=e=>'connected'===e?I:'pending'===e?f.colours.amber:f.colours.red,R=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1490,[813,779,17,974,385,85,856,899,976,804,777,1346,971,880,1491,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.SyncDeviceActions=function(){const e=(0,o.useSync)(),[f,p]=(0,s.useState)(!1),h='live'===e.mode||'offline'===e.mode;return e.venueId&&h?(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsxs)(c.default,{style:{gap:6,marginTop:6},children:[(0,b.jsx)(u.T,{size:12,children:"Disconnect this device? Your changes stay on it; open your personal invite link to connect again."}),(0,b.jsxs)(c.default,{style:{flexDirection:'row',gap:8},children:[(0,b.jsx)(t.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, disconnect",onPress:()=>{p(!1),(0,o.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:l.colours.red},children:(0,b.jsx)(u.T,{size:12,weight:"semibold",children:"Yes, disconnect"})}),(0,b.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>p(!1),style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,b.jsx)(u.T,{size:12,children:"Keep"})})]})]}):(0,b.jsx)(t.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:"Disconnect this device",onPress:()=>p(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,b.jsx)(u.T,{size:12,colour:l.colours.gold,children:"Disconnect this device\u2026"})}),(0,b.jsx)(n.WipeDevice,{compact:!0})]}):null};var s=r(d[0]),n=r(d[1]),t=e(r(d[2])),c=e(r(d[3])),o=r(d[4]),l=r(d[5]),u=r(d[6]),b=r(d[7])},1491,[17,1415,385,85,899,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1492,[]); +__d(function(e,s,o,p,t,a,f){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1493,[]); +__d(function(s,o,e,p,t,c,d){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1494,[]); +__d(function(o,s,e,f,p,t,d){"use strict";p.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1495,[]); +__d(function(o,s,p,t,d,e,n){"use strict";d.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1496,[]); +__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]})}},1497,[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},1498,[1499]); +__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},1499,[8,1500,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}))}}},1500,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1501,[]); +__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})}}},1502,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/staff-app/admin.html b/staff-app/admin.html index 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 1975b195ab29440bb56bac1541ea871fea853644..510965ab19b2760240fd023a434a413f1f6716be 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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 35e8f6663c0e6ccbe5e1e7317d581eb4e2df012d..f639dffb7d6e1c16b1a2c3edd6f92f4766b118ce 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-9e42a3b187"; +const V = "cc-staff-ccb1601105"; 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=9e42a3b187e1950f8ecec4c80778378428e7763c62c4270facd7ed7c65c5038f"]; +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=ccb16011052d2a57152a7e6623168617099ac8c884cd31a2ecc686b539471956"]; // 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 0a37e96517327608ec9b254b01df6f3920ad738d..92969fc2b6672d92317b603ba7dd1217d35ab4b5 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); })(); - +